local _, P = ... -- Separate from profile/version migrations: never reset spells, bindings, -- graphics, language or the user's ordinary action-bar assignments. P.classLayoutVersion = 7 P.petIconSize = 8 -- native 130%: pet icons now nearly match the combat buttons P.classFrameNames = { "PartyFrame", "CompactRaidFrameContainer", "UIWidgetTopCenterContainerFrame", "UIWidgetBelowMinimapContainerFrame", "UIWidgetPowerBarContainerFrame", "BossTargetFrameContainer", "PlayerPowerBarAlt", "StanceBar", "PetActionBar", "PossessActionBar", "MultiCastActionBarFrame", "MainMenuBarVehicleLeaveButton", "ExtraAbilityContainer", "PlayerCastingBarFrame", "PlayerFrame", "PetFrame", "TargetFrame", "TargetFrameToT", "RuenTargetTargetTarget", "FocusFrame", } local function setting(system, key, value) if key == nil then return end for _, entry in ipairs(system.settings or {}) do if entry.setting == key then entry.value = value; return end end system.settings = system.settings or {} system.settings[#system.settings + 1] = {setting = key, value = value} end local function anchor(system, point, x, y) system.anchorInfo = {point = point, relativeTo = "UIParent", relativePoint = "BOTTOM", offsetX = x, offsetY = y} system.isInDefaultPosition = false end local function makePlan(base) local _, class = UnitClass("player") local function dimension(name, method, fallback) local f = _G[name] if not f then return fallback end local value = f[method](f) * f:GetEffectiveScale() / UIParent:GetEffectiveScale() return value > 1 and value or fallback end local function shown(name) return _G[name] and _G[name]:IsShown() end local hasForms = GetNumShapeshiftForms and GetNumShapeshiftForms() > 0 local petClass = class == "HUNTER" or class == "WARLOCK" or class == "MAGE" local petActive = petClass or shown("PetActionBar") -- Use six units of the twelve-unit clearance above the combat rows for -- the larger pet icons, keeping the cast/unit HUD at its compact height. if petActive then base = base - 6 end local extraWidth = P.PetExtraGeometry and select(3, P.PetExtraGeometry()) or 82 local groups = { {name = "StanceBar", active = hasForms or shown("StanceBar"), width = dimension("StanceBar", "GetWidth", 30), height = dimension("StanceBar", "GetHeight", 30)}, {name = "PetActionBar", active = petActive, width = dimension("PetActionBar", "GetWidth", 408) + extraWidth, height = dimension("PetActionBar", "GetHeight", 39)}, {name = "MultiCastActionBarFrame", active = class == "SHAMAN" or shown("MultiCastActionBarFrame"), width = dimension("MultiCastActionBarFrame", "GetWidth", 230), height = dimension("MultiCastActionBarFrame", "GetHeight", 38)}, } -- Compact rows stay inside the space between player/target subframes. Known -- class controls retain their slot when temporarily hidden during combat. local rows, row = {}, {width = 0, height = 30} for _, group in ipairs(groups) do if group.active then local gap = #row > 0 and 10 or 0 if #row > 0 and row.width + gap + group.width > 300 then rows[#rows + 1] = row; row = {width = 0, height = 30}; gap = 0 end row[#row + 1] = group row.width = row.width + gap + group.width row.height = math.max(row.height, group.height) end end if #row > 0 then rows[#rows + 1] = row end local plan, top = {}, base for _, current in ipairs(rows) do local left = -current.width / 2 for _, group in ipairs(current) do plan[group.name] = {"BOTTOM", left + group.width / 2, top} left = left + group.width + 10 end -- Larger pet icons need less surrounding whitespace. Keep a clear -- five-unit gap above their row without pushing the unit HUD upward. local rowGap = #current == 1 and current[1].name == "PetActionBar" and 5 or 8 top = top + current.height + rowGap end local cast = math.max(228, top + (P.swingDockHeight or 13) + (P.swingCastGap or 18)) plan.RuenSwingTimers = {"BOTTOM", 0, cast - (P.swingCastGap or 18) - (P.swingDockHeight or 13)} local castHeight = dimension("PlayerCastingBarFrame", "GetHeight", 20) local units = math.max(258, cast + castHeight + 10) -- Unused class frames also receive safe, non-overlapping anchors. If a -- quest reveals an unusual pet/form in combat, it appears in the center -- gap above the cast bar; reflow compacts it after combat. local spare = units + 32 for _, group in ipairs(groups) do if not plan[group.name] then plan[group.name] = {"BOTTOM", 0, spare} spare = spare + group.height + 10 end end -- Native ten buttons occupy the left part of the centered twelve-button row. plan.PetActionBar[2] = plan.PetActionBar[2] - extraWidth / 2 local right = dimension("MultiBarBottomRight", "GetWidth", 495) / 2 + 14 plan.PossessActionBar = {"BOTTOMLEFT", right, base - 70} plan.MainMenuBarVehicleLeaveButton = {"BOTTOMLEFT", right + dimension("PossessActionBar", "GetWidth", 54) + 10, base - 70} plan.ExtraAbilityContainer = {"BOTTOM", shown("FocusFrame") and -300 or 0, units + 126} plan.PlayerCastingBarFrame = {"BOTTOM", 0, cast} -- At laptop widths the fixed 165-unit offset can push target information -- into the quest/right-utility column. Keep symmetric unit frames inside it. local unitWidth=math.max(dimension("PlayerFrame","GetWidth",232),dimension("TargetFrame","GetWidth",232)) local offset=math.min(165,math.max(132,UIParent:GetWidth()/2-unitWidth-dimension("MultiBarLeft","GetWidth",252)-62)) plan.PlayerFrame = {"BOTTOMRIGHT", -offset, units} plan.TargetFrame = {"BOTTOMLEFT", offset, units} -- The native target cast bar occupies the space under target-of-target. -- Put the optional third-target readout in the clear middle gap instead. plan.RuenTargetTargetTarget = {"BOTTOM",0,units+10} -- Focus uses the middle lane above the cast/target chain. Target auras -- keep their own right column; focus casts clear the primary unit frames. plan.FocusFrame = {"BOTTOM", UIParent:GetWidth()<1366 and 16 or 0, units + 110} return plan end function P.ConfigureClassSystems(layout, base) local plan = makePlan(base or 222) local E, A, I, U = Enum.EditModeSystem, Enum.EditModeActionBarSetting, Enum.EditModeActionBarSystemIndices, Enum.EditModeUnitFrameSystemIndices for _, system in ipairs(layout.systems or {}) do local kind, index, name = system.system, system.systemIndex if kind == E.ActionBar then if index == I.StanceBar then name = "StanceBar" elseif index == I.PetActionBar then name = "PetActionBar" elseif index == I.PossessActionBar then name = "PossessActionBar" end if name then setting(system, A.Orientation, Enum.ActionBarOrientation.Horizontal) setting(system, A.NumRows, 1) setting(system, A.IconPadding, name == "PetActionBar" and 0 or 2) setting(system, A.IconSize, name == "PetActionBar" and P.petIconSize or 3) end elseif kind == E.TotemActionBar then name = "MultiCastActionBarFrame" elseif kind == E.VehicleLeaveButton then name = "MainMenuBarVehicleLeaveButton" elseif kind == E.ExtraAbilities then name = "ExtraAbilityContainer" elseif kind == E.CastBar then name = "PlayerCastingBarFrame" elseif kind == E.UnitFrame then if index == U.Player then name = "PlayerFrame" elseif index == U.Target then name = "TargetFrame" elseif index == U.Focus then name = "FocusFrame" end end if name == "FocusFrame" then setting(system, Enum.EditModeUnitFrameSetting.UseLargerFrame, 0) end if name == "TargetFrame" or name == "FocusFrame" then -- Native aura layout grows away from the action rows. Do not move -- secure aura children or hook their frequent updates. setting(system, Enum.EditModeUnitFrameSetting.BuffsOnTop, 1) end if name then anchor(system, unpack(plan[name])) end end end function P.MigrateClassLayout() if InCombatLockdown() or not RuenUIDB or RuenUIDB.disabled then return end local _, class = UnitClass("player") if RuenUIDB.classLayoutVersion == P.classLayoutVersion and RuenUIDB.classLayoutClass == class then return end local manager = EditModeManagerFrame if not manager or manager:IsShown() or manager.overrideLayoutInfo then return end local active = manager:GetActiveLayoutInfo() if not P.IsOurLayout(active) then return end -- Only submit detached data to the native API. Mutating frame.systemInfo or -- the manager's shared layout table taints protected positioning in combat. local info = P.CopyEditModeLayouts() local found for _, layout in ipairs(info.layouts or {}) do if P.IsOurLayout(layout) then RuenUIDB.beforeClassLayout = RuenUIDB.beforeClassLayout or C_EditMode.ConvertLayoutInfoToString(layout) P.ConfigureClassSystems(layout) found = true end end if not found then return end P.SaveEditModeLayouts(info) RuenUIDB.classLayoutVersion = P.classLayoutVersion RuenUIDB.classLayoutClass = class end local widgetBaseScale,widgetAppliedScale function P.PositionEncounterWidgets(place,edge) local f=UIWidgetTopCenterContainerFrame if not f then return end local current=f:GetScale() if not widgetBaseScale or (widgetAppliedScale and math.abs(current-widgetAppliedScale)>.001) then widgetBaseScale=current end local width=UIParent:GetWidth() local fit=width<1366 and .9 or 1 widgetAppliedScale=widgetBaseScale*fit if math.abs(current-widgetAppliedScale)>.001 then (f.SetScaleBase or f.SetScale)(f,widgetAppliedScale) end if width<1600 then -- Leave the upper left field for the full raid. The objective score -- stays at the top, immediately left of the minimap on short screens. local right=(edge(MinimapCluster,"GetLeft") or width-240)-12 place(f,"TOPRIGHT",UIParent,"TOPLEFT",right,-12) else place(f,"TOP",UIParent,"TOP",0,-12) end end -- Reflow only after events, outside combat; never alter native visibility or -- paging. Size is measured in UIParent units, so 1080p/1440p share the same plan. function P.RefreshClassLayout(place, edge, ratio) local top = edge(MultiBar5 or MultiBarBottomRight, "GetTop") if not top or InCombatLockdown() then return end local plan = makePlan(math.max(180, top + 12)) for name, position in pairs(plan) do local f = _G[name] if f then place(f, position[1], UIParent, "BOTTOM", position[2], position[3]) end end if P.PositionSwingTimers then local cast = PlayerCastingBarFrame local width = cast and cast:GetWidth() * ratio(cast) or 208 P.PositionSwingTimers(plan, width, place) end -- The totem frame reserves all four slots even when only one is learned. -- Center the visible buttons, including summon/recall, instead of its empty -- full-level footprint. Their secure click handlers/visibility stay native. local bar = MultiCastActionBarFrame if bar and bar:IsShown() then local left, right for _, name in ipairs({"MultiCastSlotButton1", "MultiCastSlotButton2", "MultiCastSlotButton3", "MultiCastSlotButton4", "MultiCastSummonSpellButton", "MultiCastRecallSpellButton"}) do local button = _G[name] if button and button:IsShown() then local l, r = edge(button, "GetLeft"), edge(button, "GetRight") if l and r then left = left and math.min(left, l) or l; right = right and math.max(right, r) or r end end end if left and right then local position = plan.MultiCastActionBarFrame local center = UIParent:GetWidth() / 2 + position[2] place(bar, position[1], UIParent, "BOTTOM", position[2] + center - (left + right) / 2, position[3]) end end end