Advertisement
nebula169

PitBull4 boss and arena frames

Jul 16th, 2013
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 34.34 KB | None | 0 0
  1. diff --git a/GroupHeader.lua b/GroupHeader.lua
  2. index 502728e..9d75c86 100755
  3. --- a/GroupHeader.lua
  4. +++ b/GroupHeader.lua
  5. @@ -1,6 +1,5 @@
  6.  local _G = _G
  7.  local PitBull4 = _G.PitBull4
  8. -local mop_520 = select(4, GetBuildInfo()) >= 50200
  9.  
  10.  local DEBUG = PitBull4.DEBUG
  11.  local expect = PitBull4.expect
  12. @@ -21,13 +20,16 @@ function PitBull4:MakeGroupHeader(group)
  13.     if DEBUG then
  14.         expect(group, 'typeof', 'string')
  15.     end
  16. -  
  17. +
  18.     local group_db = PitBull4.db.profile.groups[group]
  19. -   local pet_based = not not group_db.unit_group:match("pet") -- this feels dirty
  20. +   local pet_based = group_db.unit_group:match("pet") and true
  21. +   local group_based = group_db.unit_group:match("^party") or group_db.unit_group:match("^raid")
  22.     local use_pet_header = pet_based and group_db.use_pet_header
  23.     local header_name
  24. -  
  25. -   if use_pet_header then
  26. +
  27. +   if not group_based then
  28. +       header_name = "PitBull4_EnemyGroups_"..group
  29. +   elseif use_pet_header then
  30.         header_name = "PitBull4_PetGroups_" .. group
  31.     else
  32.         header_name = "PitBull4_Groups_" .. group
  33. @@ -36,18 +38,16 @@ function PitBull4:MakeGroupHeader(group)
  34.     local header = _G[header_name]
  35.     if not header then
  36.         local template
  37. -       if use_pet_header then
  38. -           template = "SecureGroupPetHeaderTemplate"
  39. -       else
  40. -           template = "SecureGroupHeaderTemplate"
  41. +       if group_based then
  42. +           template = use_pet_header and "SecureGroupPetHeaderTemplate" or "SecureGroupHeaderTemplate"
  43.         end
  44.         header = CreateFrame("Frame", header_name, UIParent, template)
  45.         header:Hide() -- it will be shown later and attributes being set won't cause lag
  46. -      
  47. +
  48.         header.name = group
  49. -      
  50.         header.group_db = group_db
  51. -      
  52. +       header.group_based = group_based
  53. +
  54.         self:ConvertIntoGroupHeader(header)
  55.     elseif header.group_db ~= group_db then
  56.         -- If the frame already exists and the group_db doesn't already match the one
  57. @@ -73,6 +73,7 @@ function PitBull4:SwapGroupTemplate(group)
  58.  
  59.     local old_header = self.name_to_header[group]
  60.     local group_db = PitBull4.db.profile.groups[group]
  61. +   local group_based = group_db.unit_group:match("^party") or group_db.unit_group:match("^raid")
  62.  
  63.     if not group_db.enabled then
  64.         return
  65. @@ -83,9 +84,11 @@ function PitBull4:SwapGroupTemplate(group)
  66.     old_header:RefreshGroup()
  67.     old_header:UpdateShownState()
  68.     old_header:RecheckConfigMode()
  69. -  
  70. +
  71.     local new_name
  72. -   if group_db.use_pet_header then
  73. +   if not group_based then
  74. +       new_name = "PitBull4_EnemyGroups_"..group
  75. +   elseif group_db.use_pet_header then
  76.         new_name = "PitBull4_PetGroups_"..group
  77.     else
  78.         new_name = "PitBull4_Groups_"..group
  79. @@ -270,6 +273,10 @@ function GroupHeader:RefixSizeAndPosition()
  80.         self:Update()
  81.     end
  82.  
  83. +   if not self.group_based then
  84. +       -- reposition frames on the fake header
  85. +       self:PositionMembers()
  86. +   end
  87.  
  88.     self:ClearAllPoints()
  89.     self:SetPoint(anchor, UIParent, "CENTER", group_db.position_x / scale + x_diff, group_db.position_y / scale + y_diff)
  90. @@ -347,9 +354,13 @@ function GroupHeader:RefreshGroup(dont_refresh_children)
  91.     local enabled = group_db.enabled
  92.     local unit_group = group_db.unit_group
  93.     local party_based = unit_group:sub(1, 5) == "party"
  94. +   local group_based = party_based or unit_group:sub(1, 4) == "raid"
  95.     local include_player = party_based and group_db.include_player
  96.     local show_when = group_db.show_when
  97. -   local show_solo = include_player and show_when.solo
  98. +   local show_solo = show_when.solo
  99. +   if group_based then
  100. +       show_solo = include_player and show_solo
  101. +   end
  102.     local group_filter = not party_based and group_db.group_filter or nil
  103.     local sort_direction = group_db.sort_direction
  104.     local sort_method = group_db.sort_method
  105. @@ -359,13 +370,14 @@ function GroupHeader:RefreshGroup(dont_refresh_children)
  106.     if group_filter == "MAINTANK" then
  107.         name_list = get_main_tank_name_list()
  108.     end
  109. -  
  110. -   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
  111. -  
  112. +
  113. +   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
  114. +
  115.     if changed_units then
  116.         local old_unit_group = self.unit_group
  117.         local old_super_unit_group = self.super_unit_group
  118.         self.unit_group = unit_group
  119. +       self.group_based = group_based
  120.         self.include_player = include_player
  121.         self.show_solo = show_solo
  122.         self.group_filter = group_filter
  123. @@ -374,11 +386,9 @@ function GroupHeader:RefreshGroup(dont_refresh_children)
  124.         self.group_by = group_db.group_by
  125.         self.name_list = name_list
  126.         if DEBUG then
  127. -           if not party_based then
  128. -               expect(unit_group:sub(1, 4), '==', "raid")
  129. -           end
  130. +           expect(unit_group, 'typeof', 'string')
  131.         end
  132. -  
  133. +
  134.         if party_based then
  135.             self.super_unit_group = "party"
  136.             self.unitsuffix = unit_group:sub(6)
  137. @@ -387,6 +397,14 @@ function GroupHeader:RefreshGroup(dont_refresh_children)
  138.             self:SetAttribute("showPlayer", include_player and true or nil)
  139.             self:SetAttribute("showSolo", show_solo and true or nil)
  140.             self:SetAttribute("groupFilter", nil)
  141. +       elseif not group_based then
  142. +           if unit_group:sub(1, 4) == "boss" then
  143. +               self.super_unit_group = "boss"
  144. +               self.unitsuffix = unit_group:sub(5)
  145. +           elseif unit_group:sub(1, 5) == "arena" then
  146. +               self.super_unit_group = "arena"
  147. +               self.unitsuffix = unit_group:sub(6)
  148. +           end
  149.         else
  150.             self.super_unit_group = "raid"
  151.             self.unitsuffix = unit_group:sub(5)
  152. @@ -454,21 +472,23 @@ function GroupHeader:RefreshGroup(dont_refresh_children)
  153.     self:SetAttribute("startingIndex", 1)
  154.     self:SetAttribute("columnAnchorPoint", DIRECTION_TO_COLUMN_ANCHOR_POINT[direction])
  155.     self:SetAttribute("useOwnerUnit", 1)
  156. -  
  157. -   -- Set the attributes for the StateHeader to know when to show and hide this
  158. +
  159. +   -- Set the attributes for the StateHeader to know when to show and hide this
  160.     -- group
  161.     for k,v in pairs(show_when) do
  162. -       if k == "solo" then
  163. -           self:SetAttribute(k, enabled and show_solo and party_based)
  164. -       elseif k == "party" then
  165. -           self:SetAttribute(k, enabled and v and party_based)
  166. -       else
  167. -           self:SetAttribute(k, enabled and v)
  168. +       local value = enabled and v
  169. +       if group_based then
  170. +           if k == "solo" then
  171. +               value = enabled and show_solo and party_based
  172. +           elseif k == "party" then
  173. +               value = value and party_based
  174. +           end
  175.         end
  176. +       self:SetAttribute(k, value)
  177.     end
  178.  
  179.     self:RefixSizeAndPosition()
  180. -  
  181. +
  182.     if is_shown then
  183.         self:Show()
  184.     end
  185. @@ -548,15 +568,15 @@ local function should_show_header(config_mode, header)
  186.     if not config_mode then
  187.         return false
  188.     end
  189. -  
  190. +
  191.     if config_mode == "solo" then
  192.         return header.show_solo
  193.     end
  194. -  
  195. -   if config_mode == "party" and header.super_unit_group ~= "party" then
  196. +
  197. +   if header.group_based and config_mode == "party" and header.super_unit_group ~= "party" then
  198.         return false
  199.     end
  200. -  
  201. +
  202.     return true
  203.  end
  204.  
  205. @@ -650,10 +670,27 @@ end
  206.  -- utility function for ApplyConfigModeState, it doctors
  207.  -- up some data so don't reuse this elsewhere
  208.  local function get_group_roster_info(super_unit_group, index)
  209. -   local unit, name, subgroup, class_name, role, _
  210. +   local unit, name, subgroup, class_name, role, server, _
  211.     if super_unit_group == "raid" then
  212.         unit = "raid"..index
  213.         name, _, subgroup, _, _, class_name, _, _, _, role = GetRaidRosterInfo(index)
  214. +   elseif super_unit_group == "boss" then
  215. +       unit = "boss"..index
  216. +       if UnitExists(unit) then
  217. +           name = UnitName(unit)
  218. +           _, class_name = UnitClassBase(unit)
  219. +           subgroup = 1
  220. +       end
  221. +   elseif super_unit_group == "arena" then
  222. +       unit = "arena"..index
  223. +       if UnitExists(unit) then
  224. +           name, server = UnitName(unit)
  225. +           if (server and server ~= "") then
  226. +               name = name.."-"..server
  227. +           end
  228. +           _, class_name = UnitClass(unit)
  229. +           subgroup = 1
  230. +       end
  231.     else
  232.         if index > 0 then
  233.             unit = "party"..index
  234. @@ -790,10 +827,11 @@ function GroupHeader:ApplyConfigModeState()
  235.         return
  236.     end
  237.  
  238. -   self:SetAttribute("_ignore",true)
  239. +   local oldIgnore = self:SetAttribute("_ignore")
  240. +   self:SetAttribute("_ignore", "applyConfigModeState")
  241.  
  242.     wipe(sorting_table)
  243. -  
  244. +
  245.     local super_unit_group = self.super_unit_group
  246.     local config_mode = PitBull4.config_mode
  247.     local start, finish, step = 1, self:GetMaxUnits(true), 1
  248. @@ -822,7 +860,7 @@ function GroupHeader:ApplyConfigModeState()
  249.  
  250.         -- filter by a list of group numbers and/or classes
  251.         fill_table(wipe(token_table), strsplit(",", group_filter))
  252. -       local strict_filter = self:GetAttribute("strictFiltering")
  253. +       local strict_filtering = self:GetAttribute("strictFiltering")
  254.  
  255.         for i = start, finish, 1 do
  256.             local unit, name, subgroup, class_name, role = get_group_roster_info(super_unit_group, i)
  257. @@ -875,7 +913,7 @@ function GroupHeader:ApplyConfigModeState()
  258.         if sort_method == "NAME" then
  259.             table.sort(sorting_table, sort_on_names)
  260.         elseif sort_method == "NAMELIST" then
  261. -           table.sort(sorting_table, sort_on_namelist)
  262. +           table.sort(sorting_table, sort_on_name_list)
  263.         end
  264.     end
  265.  
  266. @@ -951,7 +989,8 @@ function GroupHeader:ApplyConfigModeState()
  267.                 frame:SetPoint(column_anchor_point, current_anchor, column_anchor_point, 0, 0)
  268.             end
  269.         elseif column_unit_count == 1 then
  270. -           local column_anchor = self:GetAttribute("child"..(frame_num - units_per_column))
  271. +           local child_num = frame_num - units_per_column
  272. +           local column_anchor = self[child_num]
  273.             frame:SetPoint(column_anchor_point, column_anchor, column_rel_point, colx_multi * column_spacing, coly_multi * column_spacing)
  274.         else
  275.             frame:SetPoint(point, current_anchor, relative_point, x_multiplier * x_offset, y_multiplier * y_offset)
  276. @@ -967,7 +1006,7 @@ function GroupHeader:ApplyConfigModeState()
  277.         current_anchor = frame
  278.     end
  279.  
  280. -   self:SetAttribute("_ignore",nil)
  281. +   self:SetAttribute("_ignore", oldIgnore)
  282.  end
  283.  GroupHeader.ApplyConfigModeState = PitBull4:OutOfCombatWrapper(GroupHeader.ApplyConfigModeState)
  284.  
  285. @@ -1021,6 +1060,10 @@ function GroupHeader:GetMaxUnits(ignore_filters)
  286.  
  287.         -- Everything else we're gonna have to go by max.
  288.         return MAX_RAID_MEMBERS
  289. +   elseif self.super_unit_group == "boss" then
  290. +       return MAX_BOSS_FRAMES
  291. +   elseif self.super_unit_group == "arena" then
  292. +       return MAX_PARTY_MEMBERS_WITH_PLAYER
  293.     else
  294.         if self.include_player then
  295.             return MAX_PARTY_MEMBERS_WITH_PLAYER
  296. @@ -1049,7 +1092,9 @@ function GroupHeader:IterateMembers(guess_num)
  297.     local num
  298.     if guess_num then
  299.         local config_mode = PitBull4.config_mode
  300. -       if config_mode == "solo" then
  301. +       if config_mode and not self.group_based then
  302. +           num = 5
  303. +       elseif config_mode == "solo" then
  304.             num = self.include_player and 1 or 0
  305.         elseif config_mode == "party" then
  306.             num = self.include_player and MAX_PARTY_MEMBERS_WITH_PLAYER or MAX_PARTY_MEMBERS
  307. @@ -1141,13 +1186,21 @@ function GroupHeader:Rename(name)
  308.     if self.name == name then
  309.         return
  310.     end
  311. -  
  312. +
  313.     local use_pet_header = self.group_db.use_pet_header
  314. -   local prefix = use_pet_header and "PitBull4_PetGroups_" or "PitBull4_Groups_"
  315. +   local group_based = self.group_db.group_based
  316. +   local prefix
  317. +   if not group_based then
  318. +       prefix = "PitBull4_EnemyGroups_"
  319. +   elseif use_pet_header then
  320. +       prefix = "PitBull4_PetGroups_"
  321. +   else
  322. +       prefix = "PitBull4_Groups_"
  323. +   end
  324.  
  325.     local old_header_name = prefix .. self.name
  326.     local new_header_name = prefix .. name
  327. -  
  328. +
  329.     PitBull4.name_to_header[self.name] = nil
  330.     PitBull4.name_to_header[name] = self
  331.     _G[old_header_name] = nil
  332. @@ -1378,9 +1431,7 @@ local initialConfigFunction = [[
  333.        header:CallMethod("InitialConfigFunction")
  334.      end
  335.  ]]
  336. -if not mop_520 then
  337. -  initialConfigFunction = initialConfigFunction:gsub("togglemenu", "menu")
  338. -end
  339. +
  340.  
  341.  --- Add the proper functions and scripts to a SecureGroupHeaderTemplate or SecureGroupPetHeaderTemplate, as well as some initialization.
  342.  -- @param frame a Frame which inherits from SecureGroupHeaderTemplate or SecureGroupPetHeaderTemplate
  343. @@ -1390,45 +1441,237 @@ function PitBull4:ConvertIntoGroupHeader(header)
  344.         expect(header, 'typeof', 'frame')
  345.         expect(header, 'frametype', 'Frame')
  346.     end
  347. -  
  348. -   -- Stop the group header from listening to UNIT_NAME_UPDATE.  
  349. -   -- Allowing it to do so is a huge performance drain since the
  350. -   -- GroupHeader's OnEvent updates the header regardless of the unit
  351. -   -- passed in the argument.  Many UNIT_NAME_UPDATE events can be
  352. -   -- generated when zoning into battlegrounds, spirit rezes in
  353. -   -- battlegrounds, pet rezes, etc.  This should prevent some
  354. -   -- stuttering isseus with BGs.  See this post for more details:
  355. -   -- http://forums.wowace.com/showthread.php?p=111494#post111494
  356. -   self:UnregisterEvent("UNIT_NAME_UPDATE")
  357.  
  358.     self.all_headers[header] = true
  359.     self.name_to_header[header.name] = header
  360. -  
  361. +
  362.     for k, v in pairs(GroupHeader__scripts) do
  363.         header:HookScript(k, v)
  364.     end
  365. -  
  366. +
  367.     for k, v in pairs(GroupHeader) do
  368.         header[k] = v
  369.     end
  370.  
  371. -   if ClickCastHeader then
  372. -       SecureHandler_OnLoad(header)
  373. -       header:SetFrameRef("clickcast_header", ClickCastHeader)
  374. -   end
  375. -  
  376. -   -- this is done to pass self in properly
  377. -   function header.initialConfigFunction(...)
  378. -       return header:InitialConfigFunction(...)
  379. -   end
  380. +   if header.group_based then
  381. +       -- Stop the group header from listening to UNIT_NAME_UPDATE.
  382. +       -- Allowing it to do so is a huge performance drain since the
  383. +       -- GroupHeader's OnEvent updates the header regardless of the unit
  384. +       -- passed in the argument.  Many UNIT_NAME_UPDATE events can be
  385. +       -- generated when zoning into battlegrounds, spirit rezes in
  386. +       -- battlegrounds, pet rezes, etc.  This should prevent some
  387. +       -- stuttering isseus with BGs.  See this post for more details:
  388. +       -- http://forums.wowace.com/showthread.php?p=111494#post111494
  389. +       header:UnregisterEvent("UNIT_NAME_UPDATE")
  390. +
  391. +       if ClickCastHeader then
  392. +           SecureHandler_OnLoad(header)
  393. +           header:SetFrameRef("clickcast_header", ClickCastHeader)
  394. +       end
  395. +
  396. +       -- this is done to pass self in properly
  397. +       function header.initialConfigFunction(...)
  398. +           return header:InitialConfigFunction(...)
  399. +       end
  400. +
  401. +       if header.group_db.unit_group:sub(1, 4) == "raid" then
  402. +           header:SetAttribute("initialConfigFunction", initialConfigFunction:gsub("togglemenu", "menu"))
  403. +       else
  404. +           header:SetAttribute("initialConfigFunction", initialConfigFunction)
  405. +       end
  406.  
  407. -   if header.group_db.unit_group:sub(1, 4) == "raid" then
  408. -     header:SetAttribute("initialConfigFunction", initialConfigFunction:gsub("togglemenu", "menu"))
  409.     else
  410. -       header:SetAttribute("initialConfigFunction", initialConfigFunction)
  411. +       -- set up our fake header for non party/raid group frames
  412. +
  413. +       -- allow events to force an update
  414. +       header:SetScript("OnEvent", function(self, event, arg1, ...)
  415. +           if not self:IsVisible() or not self.group_db.enabled then return end
  416. +
  417. +           if event == "UPDATE_BATTLEFIELD_STATUS" and GetBattlefieldStatus(arg1) ~= "active" then
  418. +               return
  419. +           elseif event == "UNIT_TARGETABLE_CHANGED" and not arg1:match(self.super_unit_group) then
  420. +               return
  421. +           end
  422. +
  423. +           self:UpdateMembers()
  424. +       end)
  425. +
  426. +       -- set up the unit/unitsuffix and register update events
  427. +       local unit_group = header.group_db.unit_group
  428. +       if unit_group:sub(1, 4) == "boss" then
  429. +           header.super_unit_group = "boss"
  430. +           header.unitsuffix = unit_group:sub(5)
  431. +
  432. +           header:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT")
  433. +           header:RegisterEvent("UNIT_TARGETABLE_CHANGED")
  434. +       elseif unit_group:sub(1, 5) == "arena" then
  435. +           header.super_unit_group = "arena"
  436. +           header.unitsuffix = unit_group:sub(6)
  437. +
  438. +           header:RegisterEvent("UPDATE_BATTLEFIELD_STATUS")
  439. +       end
  440. +
  441. +       if header.unitsuffix == "" then
  442. +           header.unitsuffix = nil
  443. +       end
  444. +       local unitsuffix = header.unitsuffix
  445. +
  446. +       local frame_OnEvent = function(self, event, ...)
  447. +           self:Update()
  448. +       end
  449. +
  450. +       for index = 1, header:GetMaxUnits(true) do
  451. +           local unit = header.super_unit_group .. index -- want the base unit as "unit" before getting wacky in "unitsuffix" (seemed awkward to me)
  452. +
  453. +           -- make a singleton unit frame and tack it onto our header
  454. +           local frame_name = header:GetName() .. "UnitButton" .. index
  455. +           local frame = _G[frame_name]
  456. +           if not frame then
  457. +               frame = CreateFrame("Button", frame_name, header, "SecureUnitButtonTemplate,SecureHandlerBaseTemplate,PitBull4_UnitTemplate_Clique")
  458. +               frame:Hide()
  459. +
  460. +               header[index] = frame
  461. +               header:InitialConfigFunction()
  462. +               frame:SetAttribute("*type1", "target")
  463. +               frame:SetAttribute("*type2", "togglemenu")
  464. +
  465. +               frame:SetAttribute("unit", unit)
  466. +               frame:SetAttribute("unitsuffix", unitsuffix)
  467. +
  468. +               frame:SetScript("OnEvent", frame_OnEvent)
  469. +               frame:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
  470. +               frame:RegisterUnitEvent("ARENA_OPPONENT_UPDATE", unit)
  471. +
  472. +               frame:WrapScript(frame, "OnAttributeChanged", [[
  473. +          if name == "config_mode" and self:GetAttribute("config_mode") then
  474. +            self:Show()
  475. +          end
  476. +        ]])
  477. +           end
  478. +
  479. +           RegisterUnitWatch(frame)
  480. +
  481. +           frame:RefreshLayout()
  482. +
  483. +           frame:UpdateGUID(UnitGUID(frame.unit))
  484. +       end
  485.     end
  486. -  
  487. +
  488.     header:RefreshGroup(true)
  489. -  
  490. +
  491.     header:SetMovable(true)
  492.  end
  493. +
  494. +
  495. +--- Position all the children of a fake group header.
  496. +-- duplicate code from SecureGroupHeader_Update IN TWO PLACES!
  497. +-- @usage header:PositionMembers()
  498. +function GroupHeader:PositionMembers()
  499. +   if not self[1] then return end -- frames not set up (:SwapGroupTemplate from a disabled header)
  500. +
  501. +   local oldIgnore = self:GetAttribute("_ignore")
  502. +   self:SetAttribute("_ignore", "configureChildren")
  503. +
  504. +   wipe(sorting_table)
  505. +
  506. +   local start, finish, step = 1, self:GetMaxUnits(), 1
  507. +   local super_unit_group = self.super_unit_group
  508. +   for i = start, finish, step do
  509. +       sorting_table[#sorting_table + 1] = super_unit_group .. i
  510. +   end
  511. +
  512. +   local point = self:GetAttribute("point") or "TOP"
  513. +   local relative_point, x_offset_mult, y_offset_mult = get_relative_point_anchor(point)
  514. +   local x_multiplier, y_multiplier = abs(x_offset_mult), abs(y_offset_mult)
  515. +   local x_offset = self:GetAttribute("xOffset") or 0
  516. +   local y_offset = self:GetAttribute("yOffset") or 0
  517. +   local sort_dir = self:GetAttribute("sortDir") or "ASC"
  518. +   local column_spacing = self:GetAttribute("columnSpacing") or 0
  519. +   local units_per_column = self:GetAttribute("unitsPerColumn")
  520. +   local num_displayed = #sorting_table
  521. +   local num_columns
  522. +   if units_per_column and num_displayed > units_per_column then
  523. +       num_columns = min( ceil(num_displayed / units_per_column), (self:GetAttribute("maxColumns") or 1) )
  524. +   else
  525. +       units_per_column = num_displayed
  526. +       num_columns = 1
  527. +   end
  528. +
  529. +   if sort_dir == "DESC" then
  530. +       start, finish, step = finish, start, -1
  531. +   end
  532. +
  533. +   local column_anchor_point, column_rel_point, colx_multi, coly_multi
  534. +   if num_columns > 1 then
  535. +       column_anchor_point = self:GetAttribute("columnAnchorPoint")
  536. +       column_rel_point, colx_multi, coly_multi = get_relative_point_anchor(column_anchor_point)
  537. +   end
  538. +
  539. +   local frame_num = 0
  540. +   local column_num = 1
  541. +   local column_unit_count = 0
  542. +   local current_anchor = self
  543. +   for i = start, finish, step do
  544. +       frame_num = frame_num + 1
  545. +       column_unit_count = column_unit_count + 1
  546. +       if column_unit_count > units_per_column then
  547. +           column_unit_count = 1
  548. +           column_num = column_num + 1
  549. +       end
  550. +
  551. +       local frame = self[frame_num]
  552. +       if not frame then
  553. +           break
  554. +       end
  555. +       if frame_num == 1 then
  556. +           frame:SetPoint(point, current_anchor, point, 0, 0)
  557. +           if column_anchor_point then
  558. +               frame:SetPoint(column_anchor_point, current_anchor, column_anchor_point, 0, 0)
  559. +           end
  560. +       elseif column_unit_count == 1 then
  561. +           local column_anchor = self[frame_num - units_per_column]
  562. +           frame:SetPoint(column_anchor_point, column_anchor, column_rel_point, colx_multi * column_spacing, coly_multi * column_spacing)
  563. +       else
  564. +           frame:SetPoint(point, current_anchor, relative_point, x_multiplier * x_offset, y_multiplier * y_offset)
  565. +       end
  566. +
  567. +       local old_unit = frame:GetAttribute("unit")
  568. +       local unit = sorting_table[i]
  569. +       frame:SetAttribute("unit", unit)
  570. +       if old_unit ~= unit then
  571. +           -- update our unit event references
  572. +           frame:UnregisterEvent("UNIT_NAME_UPDATE")
  573. +           frame:UnregisterEvent("ARENA_OPPONENT_UPDATE")
  574. +           frame:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
  575. +           frame:RegisterUnitEvent("ARENA_OPPONENT_UPDATE", unit)
  576. +
  577. +           frame:Update()
  578. +       end
  579. +
  580. +       current_anchor = frame
  581. +   end
  582. +
  583. +   local frame_width = self[1]:GetWidth()
  584. +   local frame_height = self[1]:GetHeight()
  585. +   if num_displayed > 0 then
  586. +       local width = x_multiplier * (units_per_column - 1) * frame_width + ( (units_per_column - 1) * (x_offset * x_offset_mult) ) + frame_width
  587. +       local height = y_multiplier * (units_per_column - 1) * frame_height + ( (units_per_column - 1) * (y_offset * y_offset_mult) ) + frame_height
  588. +
  589. +       if column_num > 1 then
  590. +           width = width + ( (column_num - 1) * abs(colx_multi) * (width + column_spacing) )
  591. +           height = height + ( (column_num - 1) * abs(coly_multi) * (height + column_spacing) )
  592. +       end
  593. +
  594. +       self:SetWidth(width)
  595. +       self:SetHeight(height)
  596. +   else
  597. +       local min_width = self:GetAttribute("minWidth") or (y_multiplier * frame_width)
  598. +       local min_height = self:GetAttribute("minHeight") or (x_multiplier * frame_height)
  599. +       self:SetWidth( max(min_width, 0.1) )
  600. +       self:SetHeight( max(min_height, 0.1) )
  601. +   end
  602. +
  603. +   self:SetAttribute("_ignore", oldIgnore)
  604. +end
  605. +GroupHeader.PositionMembers = PitBull4:OutOfCombatWrapper(GroupHeader.PositionMembers)
  606. +
  607. diff --git a/Main.lua b/Main.lua
  608. index 5bae7dd..5700893 100755
  609. --- a/Main.lua
  610. +++ b/Main.lua
  611. @@ -20,12 +20,21 @@ local UNIT_GROUPS = {
  612.     "partypet",
  613.     "partypettarget",
  614.     "partypettargettarget",
  615. +   "arena",
  616. +   "arenatarget",
  617. +   "arenatargettarget",
  618. +   "arenapet",
  619. +   "arenapettarget",
  620. +   "arenapettargettarget",
  621.     "raid",
  622.     "raidtarget",
  623.     "raidtargettarget",
  624.     "raidpet",
  625.     "raidpettarget",
  626.     "raidpettargettarget",
  627. +   "boss",
  628. +   "bosstarget",
  629. +   "bosstargettarget",
  630.  }
  631.  
  632.  local NORMAL_UNITS = {
  633. @@ -39,9 +48,16 @@ for i = 1, MAX_PARTY_MEMBERS do
  634.     NORMAL_UNITS[#NORMAL_UNITS+1] = "party" .. i
  635.     NORMAL_UNITS[#NORMAL_UNITS+1] = "partypet" .. i
  636.  end
  637. +for i = 1, 5 do
  638. +   NORMAL_UNITS[#NORMAL_UNITS+1] = "arena" .. i
  639. +   NORMAL_UNITS[#NORMAL_UNITS+1] = "arenapet" .. i
  640. +end
  641.  for i = 1, MAX_RAID_MEMBERS do
  642.     NORMAL_UNITS[#NORMAL_UNITS+1] = "raid" .. i
  643.  end
  644. +for i = 1, MAX_BOSS_FRAMES do
  645. +   NORMAL_UNITS[#NORMAL_UNITS+1] = "boss" .. i
  646. +end
  647.  
  648.  do
  649.     local tmp = NORMAL_UNITS
  650. @@ -274,7 +290,6 @@ do
  651.     end
  652.    
  653.     local wipe = _G.wipe
  654. -  
  655.     --- Delete a table, clearing it and putting it back into the queue
  656.     -- @usage local t = PitBull4.new()
  657.     -- t = del(t)
  658. @@ -863,7 +878,7 @@ end
  659.  function PitBull4:IterateHeadersForSuperUnitGroup(super_unit_group)
  660.     if DEBUG then
  661.         expect(super_unit_group, 'typeof', 'string')
  662. -       expect(super_unit_group, 'inset', 'party;raid')
  663. +       expect(super_unit_group, 'inset', 'party;raid;boss;arena')
  664.     end
  665.    
  666.     local headers = rawget(super_unit_group_to_headers, super_unit_group)
  667. @@ -1154,7 +1169,6 @@ do
  668.         end
  669.        
  670.         local name = GetAddOnInfo(i)
  671. -      
  672.         -- must start with PitBull4_
  673.         local module_name = name:match("^PitBull4_(.*)$")
  674.         if not module_name then
  675. @@ -1279,7 +1293,7 @@ function PitBull4:OnProfileChanged()
  676.             self.ClassOrder[#self.ClassOrder + 1] = v
  677.         end
  678.     end
  679. -  
  680. +
  681.     -- Notify modules that the profile has changed.
  682.     for _, module in PitBull4:IterateEnabledModules() do
  683.         if module.OnProfileChanged then
  684. diff --git a/Modules/HideBlizzard/HideBlizzard.lua b/Modules/HideBlizzard/HideBlizzard.lua
  685. index cdb3443..8f1a773 100755
  686. --- a/Modules/HideBlizzard/HideBlizzard.lua
  687. +++ b/Modules/HideBlizzard/HideBlizzard.lua
  688. @@ -21,6 +21,7 @@ PitBull4_HideBlizzard:SetDefaults({}, {
  689.     aura = false,
  690.     runebar = true,
  691.     altpower = false,
  692. +   boss = true,
  693.  })
  694.  
  695.  function PitBull4_HideBlizzard:OnEnable()
  696. @@ -232,6 +233,26 @@ function showers:altpower()
  697.     UnitPowerBarAlt_UpdateAll(PlayerPowerBarAlt)
  698.  end
  699.  
  700. +function hiders:boss()
  701. +   for i=1, MAX_BOSS_FRAMES do
  702. +       local frame = _G["Boss"..i.."TargetFrame"]
  703. +       frame:UnregisterAllEvents()
  704. +       frame:Hide()
  705. +   end
  706. +end
  707. +
  708. +function showers:boss()
  709. +   for i=1, MAX_BOSS_FRAMES do
  710. +       local frame = _G["Boss"..i.."TargetFrame"]
  711. +       if i == 1 then
  712. +           BossTargetFrame_OnLoad(frame, "boss1", "INSTANCE_ENCOUNTER_ENGAGE_UNIT")
  713. +       else
  714. +           BossTargetFrame_OnLoad(frame, "boss"..i)
  715. +       end
  716. +       Target_Spellbar_OnEvent(frame.spellbar, "INSTANCE_ENCOUNTER_ENGAGE_UNIT")
  717. +   end
  718. +end
  719. +
  720.  for k, v in pairs(hiders) do
  721.     hiders[k] = PitBull4:OutOfCombatWrapper(v)
  722.  end
  723. @@ -323,5 +344,12 @@ PitBull4_HideBlizzard:SetGlobalOptionsFunction(function(self)
  724.         get = get,
  725.         set = set,
  726.         hidden = hidden,
  727. +   }, 'boss', {
  728. +       type = 'toggle',
  729. +       name = L["Boss"],
  730. +       desc = L["Hides the standard boss frames."],
  731. +       get = get,
  732. +       set = set,
  733. +       hidden = hidden,
  734.     }
  735.  end)
  736. diff --git a/Modules/LuaTexts/ScriptEnv.lua b/Modules/LuaTexts/ScriptEnv.lua
  737. index d6dd5e6..916b3ae 100755
  738. --- a/Modules/LuaTexts/ScriptEnv.lua
  739. +++ b/Modules/LuaTexts/ScriptEnv.lua
  740. @@ -53,6 +53,14 @@ setmetatable(UnitToLocale, {__index=function(self, unit)
  741.             local num = unit:match("^party(%d)$")
  742.             self[unit] = L["Party member #%d"]:format(num)
  743.             return self[unit]
  744. +       elseif unit:find("^arena%d$") then
  745. +           local num = unit:match("^arena(%d)$")
  746. +           self[unit] = L["Arena enemy #%d"]:format(num)
  747. +           return self[unit]
  748. +       elseif unit:find("^boss%d$") then
  749. +           local num = unit:match("^boss(%d)$")
  750. +           self[unit] = L["Boss #%d"]:format(num)
  751. +           return self[unit]
  752.         elseif unit:find("^raid%d%d?$") then
  753.             local num = unit:match("^raid(%d%d?)$")
  754.             self[unit] = L["Raid member #%d"]:format(num)
  755. @@ -61,6 +69,10 @@ setmetatable(UnitToLocale, {__index=function(self, unit)
  756.             local num = unit:match("^partypet(%d)$")
  757.             self[unit] = UnitToLocale["party" .. num .. "pet"]
  758.             return self[unit]
  759. +       elseif unit:find("^arenapet%d$") then
  760. +           local num = unit:match("^arenapet(%d)$")
  761. +           self[unit] = UnitToLocale["arena" .. num .. "pet"]
  762. +           return self[unit]
  763.         elseif unit:find("^raidpet%d%d?$") then
  764.             local num = unit:match("^raidpet(%d%d?)$")
  765.             self[unit] = UnitToLocale["raid" .. num .. "pet"]
  766. diff --git a/Options/Units.lua b/Options/Units.lua
  767. index 87267db..c69eb82 100755
  768. --- a/Options/Units.lua
  769. +++ b/Options/Units.lua
  770. @@ -367,7 +367,11 @@ function PitBull4.Options.get_unit_options()
  771.             return t
  772.         end,
  773.         get = get,
  774. -       set = set_with_refresh_group_shown,
  775. +       set = function(info,value)
  776. +           if set(info, value) then
  777. +               PitBull4:SwapGroupTemplate(CURRENT_GROUP)
  778. +           end
  779. +       end,
  780.         disabled = disabled,
  781.         width = 'double',
  782.     }
  783. @@ -615,6 +619,10 @@ function PitBull4.Options.get_unit_options()
  784.         GROUP = L["By group"],
  785.     }
  786.    
  787. +   local other_values = {
  788. +       INDEX = L["By index"],
  789. +   }
  790. +  
  791.     group_layout_args.sort_method = {
  792.         name = L["Sort method"],
  793.         desc = L["How to sort the frames within the group."],
  794. @@ -622,15 +630,17 @@ function PitBull4.Options.get_unit_options()
  795.         order = next_order(),
  796.         values = function(info)
  797.             local unit_group = get_group_db().unit_group
  798. -           if unit_group:sub(1, 5) == "party" then
  799. +           if unit_group:sub(1, 4) == "raid" then
  800. +               return raid_values
  801. +           elseif unit_group:sub(1, 5) == "party" then
  802.                 return party_values
  803.             else
  804. -               return raid_values
  805. +               return other_values
  806.             end
  807.         end,
  808.         get = function(info)
  809.             local db = get_group_db()
  810. -           if db.unit_group:sub(1, 5) ~= "party" then
  811. +           if db.unit_group:sub(1, 4) == "raid" then
  812.                 local group_by = db.group_by
  813.                 if group_by == "CLASS" or group_by == "GROUP" then
  814.                     return group_by
  815. @@ -774,7 +784,8 @@ function PitBull4.Options.get_unit_options()
  816.         end,
  817.         disabled = disabled,
  818.         hidden = function(info)
  819. -           return not get_group_db().unit_group:match("pet")
  820. +           local unit_group = get_group_db().unit_group
  821. +           return not unit_group:match("pet") or unit_group:match("^arena")
  822.         end,
  823.     }
  824.    
  825. @@ -860,6 +871,7 @@ function PitBull4.Options.get_unit_options()
  826.         type = 'multiselect',
  827.         values = function(info)
  828.             local unit_group = get_group_db().unit_group
  829. +           local group_based = get_group_db().group_based
  830.            
  831.             local party_based = unit_group:sub(1, 5) == "party"
  832.            
  833. @@ -871,6 +883,12 @@ function PitBull4.Options.get_unit_options()
  834.                 end
  835.                 t.party = L["Party"]
  836.             end
  837. +           if not group_based then
  838. +               if unit_group:sub(1, 5) ~= "arena" then
  839. +                   t.solo = L["Solo"]
  840. +               end
  841. +               t.party = L["Party"]
  842. +           end
  843.            
  844.             t.raid = L["5-man raid"]
  845.             t.raid10 = L["10-man raid"]
  846. @@ -891,8 +909,8 @@ function PitBull4.Options.get_unit_options()
  847.            
  848.             db.show_when[key] = value
  849.            
  850. -           refresh_group('groups')
  851.             for header in PitBull4:IterateHeadersForName(CURRENT_GROUP) do
  852. +               header:RefreshGroup(true)
  853.                 header:UpdateShownState()
  854.             end
  855.         end,
  856. @@ -970,9 +988,9 @@ function PitBull4.Options.get_unit_options()
  857.             local db = get_group_db()
  858.            
  859.             local unit_group = db.unit_group
  860. -           local party_based = unit_group:sub(1, 5) == "party"
  861. +           local raid_based = unit_group:sub(1, 4) == "raid"
  862.            
  863. -           return party_based -- only show in raid
  864. +           return not raid_based -- only show in raid
  865.         end
  866.     }
  867.    
  868. diff --git a/UnitFrame.lua b/UnitFrame.lua
  869. index 8177050..de0eabc 100755
  870. --- a/UnitFrame.lua
  871. +++ b/UnitFrame.lua
  872. @@ -5,8 +5,6 @@ local L = PitBull4.L
  873.  local DEBUG = PitBull4.DEBUG
  874.  local expect = PitBull4.expect
  875.  
  876. -local mop_520 = select(4,GetBuildInfo()) >= 50200
  877. -
  878.  -- CONSTANTS ----------------------------------------------------------------
  879.  
  880.  local MODULE_UPDATE_ORDER = {
  881. @@ -48,7 +46,7 @@ local Singleton_OnAttributeChanged = [[
  882.  
  883.  --- Make a singleton unit frame.
  884.  -- @param unit the UnitID of the frame in question
  885. --- @usage local frame = PitBull4:MakeSingletonFrame("player")
  886. +-- @usage PitBull4:MakeSingletonFrame("player")
  887.  function PitBull4:MakeSingletonFrame(unit)
  888.     if DEBUG then
  889.         expect(unit, 'typeof', 'string')
  890. @@ -199,40 +197,48 @@ end)
  891.  local PitBull4_UnitFrame_DropDown = CreateFrame("Frame", "PitBull4_UnitFrame_DropDown", UIParent, "UIDropDownMenuTemplate")
  892.  UnitPopupFrames[#UnitPopupFrames+1] = "PitBull4_UnitFrame_DropDown"
  893.  
  894. --- from a unit, figure out the proper menu and, if appropriate, the corresponding ID
  895. +-- from a unit, figure out the proper menu and, if appropriate, the corresponding ID (updated from SECURE_ACTIONS.togglemenu)
  896.  local function figure_unit_menu(unit)
  897. -   if unit == "focus" then
  898. -       return "FOCUS"
  899. -   end
  900. -
  901. -   if UnitIsUnit(unit, "player") then
  902. -       return "SELF"
  903. -   end
  904. -
  905. -   if UnitIsUnit(unit, "vehicle") then
  906. -       -- NOTE: vehicle check must come before pet check for accuracy's sake because
  907. -       -- a vehicle may also be considered your pet
  908. -       return "VEHICLE"
  909. -   end
  910. -
  911. -   if UnitIsUnit(unit, "pet") then
  912. -       return "PET"
  913. -   end
  914. -
  915. -   if not UnitIsPlayer(unit) then
  916. -       return "TARGET"
  917. -   end
  918. -
  919. -   local id = UnitInRaid(unit)
  920. -   if id then
  921. -       return "RAID_PLAYER", id
  922. -   end
  923. -
  924. -   if UnitInParty(unit) then
  925. -       return "PARTY"
  926. +   local unitType = string.match(unit, "^([a-z]+)[0-9]+$") or unit
  927. +
  928. +   -- Mimic the default UI and prefer the relevant units menu when possible
  929. +   local menu, id = "PLAYER", nil
  930. +   if unitType == "raid" then
  931. +       menu = "RAID"
  932. +   elseif unitType == "party" then
  933. +       menu = "PARTY"
  934. +   elseif unitType == "boss" then
  935. +       menu = "BOSS"
  936. +   elseif unitType == "focus" then
  937. +       menu = "FOCUS"
  938. +   elseif unitType == "arenapet" or unitType == "arena" then
  939. +       menu = "ARENAENEMY"
  940. +   -- Then try and detect the unit type and show the most relevant menu we can find
  941. +   elseif UnitIsUnit(unit, "player") then
  942. +       menu = "SELF"
  943. +   elseif UnitIsUnit(unit, "vehicle") then
  944. +       menu = "VEHICLE"
  945. +   elseif UnitIsUnit(unit, "pet") then
  946. +       menu = "PET"
  947. +   elseif UnitIsOtherPlayersBattlePet(unit) then
  948. +       menu = "OTHERBATTLEPET"
  949. +   elseif UnitIsOtherPlayersPet(unit) then
  950. +       menu = "OTHERPET"
  951. +   -- Last ditch checks
  952. +   elseif UnitIsPlayer(unit) then
  953. +       id = UnitInRaid(unit)
  954. +       if ( id ) then
  955. +           menu = "RAID_PLAYER"
  956. +       elseif UnitInParty(unit) then
  957. +           menu = "PARTY"
  958. +       else
  959. +           menu = "PLAYER"
  960. +       end
  961. +   elseif UnitIsUnit(unit, "target") then
  962. +       menu = "TARGET"
  963.     end
  964.  
  965. -   return "PLAYER"
  966. +   return menu, id
  967.  end
  968.  
  969.  local munged_unit_menus = {}
  970. @@ -565,7 +571,7 @@ function PitBull4:ConvertIntoUnitFrame(frame, isExampleFrame)
  971.             if frame.is_singleton then
  972.                 frame:SetMovable(true)
  973.               frame:SetAttribute("*type1", "target")
  974. -             frame:SetAttribute("*type2", mop_520 and "togglemenu" or "menu")
  975. +             frame:SetAttribute("*type2", "togglemenu")
  976.             end
  977.             frame:RegisterForDrag("LeftButton")
  978.             frame:RegisterForClicks("AnyUp")
  979. @@ -802,7 +808,6 @@ function UnitFrame:Update(same_guid, update_layout)
  980.     end
  981.    
  982.     local changed = update_layout
  983. -  
  984.     for _, module_type in ipairs(MODULE_UPDATE_ORDER) do
  985.         for _, module in PitBull4:IterateModulesOfType(module_type) do
  986.             changed = module:Update(self, true, same_guid) or changed
  987. diff --git a/Utils.lua b/Utils.lua
  988. index 6dd7148..00731e8 100755
  989. --- a/Utils.lua
  990. +++ b/Utils.lua
  991. @@ -89,6 +89,13 @@ do
  992.         focus = true,
  993.         target = true,
  994.     }
  995. +   for i = 1, 5 do
  996. +       valid_singleton_unit_ids["arena" .. i] = true
  997. +       valid_singleton_unit_ids["arenapet" .. i] = true
  998. +   end
  999. +   for i = 1, MAX_BOSS_FRAMES do
  1000. +       valid_singleton_unit_ids["boss" .. i] = true
  1001. +   end
  1002.     setmetatable(valid_singleton_unit_ids, target_same_mt)
  1003.    
  1004.     --- Return whether the UnitID provided is a singleton
  1005. @@ -110,6 +117,11 @@ do
  1006.         partypet = true,
  1007.         raid = true,
  1008.         raidpet = true,
  1009. +       boss = true,
  1010. +       arena = true,
  1011. +       arenapet = true,
  1012. +       battleground = true,
  1013. +       battlegroundpet = true,
  1014.     }
  1015.     setmetatable(valid_classifications, target_same_mt)
  1016.    
  1017. @@ -135,6 +147,11 @@ do
  1018.         partypet = true,
  1019.         raid = true,
  1020.         raidpet = true,
  1021. +       boss = true,
  1022. +       arena = true,
  1023. +       arenapet = true,
  1024. +       battleground = true,
  1025. +       battlegroundpet = true,
  1026.     }
  1027.    
  1028.     --- Return whether the classification provided is considered "wacky"
  1029. @@ -157,10 +174,16 @@ do
  1030.         party_sing = L["Party"],
  1031.         partypet = L["Party pets"],
  1032.         partypet_sing = L["Party pet"],
  1033. +       arena = L["Arena"],
  1034. +       arena_sing = L["Arena"],
  1035. +       arenapet = L["Arena pets"],
  1036. +       arenapet_sing = L["Arena pet"],
  1037.         raid = L["Raid"],
  1038.         raid_sing = L["Raid"],
  1039.         raidpet = L["Raid pets"],
  1040.         raidpet_sing = L["Raid pet"],
  1041. +       boss = L["Boss"],
  1042. +       boss_sing = L["Boss"],
  1043.         mouseover = L["Mouse-over"],
  1044.         focus = L["Focus"],
  1045.         maintank = L["Main tanks"],
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement