---@class GrimmsUltrawide
local GU = LibStub("AceAddon-3.0"):GetAddon("GrimmsUltrawide")

-- Buff/Debuff and Objective Tracker frame positions, exported from a live
-- Blizzard Edit Mode layout named "atrocityUI". 1440p only.
local S = "2 50 0 0 1 7 7 UIParent 0.0 45.0 -1 ##$$%/&('%)$+#,$ 0 1 1 7 7 UIParent 0.0 45.0 -1 ##$$%/&('%(#,$ 0 2 1 7 7 UIParent 0.0 45.0 -1 ##$$%/&('%(#,$ 0 3 1 5 5 UIParent -5.0 -77.0 -1 #$$$%1&('%(#,$ 0 4 1 5 5 UIParent -5.0 -77.0 -1 #$$$%/&('%(#,$ 0 5 1 1 4 UIParent 0.0 0.0 -1 ##$$%/&('%(#,$ 0 6 1 1 4 UIParent 0.0 -50.0 -1 ##$$%/&('%(#,$ 0 7 1 1 4 UIParent 0.0 -100.0 -1 ##$$%/&('%(#,$ 0 10 1 7 7 UIParent 0.0 45.0 -1 ##$$&('% 0 11 1 7 7 UIParent 0.0 45.0 -1 ##$$&('%,# 0 12 1 7 7 UIParent 0.0 45.0 -1 ##$$&('% 1 -1 1 4 4 UIParent 0.0 0.0 -1 ##$#%# 2 -1 1 2 2 UIParent 0.0 0.0 -1 ##$#%( 3 0 1 8 7 UIParent -300.0 250.0 -1 $#3# 3 1 1 6 7 UIParent 300.0 250.0 -1 %#3# 3 2 1 6 7 UIParent 520.0 265.0 -1 %#&#3# 3 3 0 0 0 UIParent 627.0 -654.0 -1 '$(#)#-Q.3/#1$3#5%6(7-7$8( 3 4 0 0 0 UIParent 2.0 -919.0 -1 ,$-1.5/#0#1#2(5%6'7-7$8( 3 5 1 5 5 UIParent 0.0 0.0 -1 &#*$3# 3 6 1 5 5 UIParent 0.0 0.0 -1 -#.#/#4$5#6(7-7$8( 3 7 1 4 4 UIParent 0.0 0.0 -1 3# 4 -1 1 7 7 UIParent 0.0 45.0 -1 # 5 -1 1 7 7 UIParent 0.0 45.0 -1 # 6 0 0 0 0 UIParent 2748.5 -1.0 -1 ##$#%#&/(()( 6 1 0 0 0 UIParent 2608.0 -227.0 -1 ##$#%#'3(()(-# 6 2 1 1 1 UIParent 0.0 -25.0 -1 ##$#%$&.(()(+#,-,$ 7 -1 0 1 1 UIParent -993.0 -2.0 -1 # 8 -1 0 0 0 UIParent 11.0 -1174.0 -1 #'$s%%&A 9 -1 0 8 8 UIParent -370.0 216.0 -1 # 10 -1 0 4 4 UIParent 348.0 53.0 -1 # 11 -1 0 8 8 UIParent -1.0 267.0 -1 # 12 -1 0 5 5 UIParent -2.0 112.6 -1 #6$#%% 13 -1 0 5 5 UIParent -2.0 -435.3 -1 ##$#%)&- 14 -1 1 2 2 MicroButtonAndBagsBar 0.0 10.0 -1 ##$#%( 15 0 1 7 7 StatusTrackingBarManager 0.0 0.0 -1 &- 15 1 1 7 7 StatusTrackingBarManager 0.0 17.0 -1 &- 16 -1 1 5 5 UIParent 0.0 0.0 -1 #( 17 -1 0 1 1 UIParent -0.0 -189.0 -1 ## 18 -1 0 2 2 UIParent -297.0 -289.0 -1 #- 19 -1 1 7 7 UIParent 0.0 0.0 -1 ## 20 0 0 4 4 UIParent 0.0 -286.0 -1 ##$7%$&('((-($)#+$,$-# 20 1 0 0 0 UIParent 1190.3 -1017.2 -1 ##$2%$&('((-($)#+$,$-# 20 2 0 4 4 UIParent 0.0 -139.0 -1 ##$$%$&('((-($)#+$,$-# 20 3 1 7 7 UIParent 420.0 430.0 -1 #$$$%#&('((-($)#*#+$,$-#.-.$ 21 -1 1 7 7 UIParent -410.0 380.0 -1 ##%#&#'((()#*-*$+#,&-#.#/(0#1# 22 0 1 8 7 UIParent -457.0 336.0 -1 #$$$%#&('((#)U*$+$,$-#.#/U0% 22 1 1 1 1 UIParent 0.0 -40.0 -1 &('()U*#+$ 22 2 1 1 1 UIParent 0.0 -90.0 -1 &('()U*#+$ 22 3 1 1 1 UIParent 0.0 -130.0 -1 &('()U*#+$ 23 -1 0 8 8 UIParent -11.0 3.0 -1 ##$%%#&8'z(#)U+$,$-+.(/#"

local LAYOUT_NAME = "atrocityUI Ultrawide"

---Imports and activates the Buff/Debuff and Objective Tracker Edit Mode
---layout. Adapted from AtrocityUI's own EditMode.lua SetEditMode function -
---we don't have access to AtrocityUI's internal aUI.Toast/RefreshImportStatus/
---atrocityUIDB helpers, so this uses GU:Print and skips that bookkeeping.
function GU:ImportEllesmereBuffsObjectivesEditMode()
    if InCombatLockdown and InCombatLockdown() then return end

    local layoutInfo = C_EditMode.ConvertStringToLayoutInfo(S)
    if not layoutInfo then return end

    layoutInfo.layoutName = LAYOUT_NAME
    layoutInfo.layoutType = Enum.EditModeLayoutType.Account

    local layoutsInfo = C_EditMode.GetLayouts()
    layoutsInfo.layouts = layoutsInfo.layouts or {}

    local customIndex
    for i, layout in ipairs(layoutsInfo.layouts) do
        if layout.layoutName == LAYOUT_NAME then
            layoutsInfo.layouts[i] = layoutInfo
            customIndex = i
            break
        end
    end

    if not customIndex then
        if #layoutsInfo.layouts >= 5 then
            self:Print("Edit Mode layout limit reached (5). Delete a layout in Edit Mode and try again.")
            return
        end
        table.insert(layoutsInfo.layouts, layoutInfo)
        customIndex = #layoutsInfo.layouts
    end

    C_EditMode.SaveLayouts(layoutsInfo)

    -- Activate for current spec
    local activeIndex = Enum.EditModePresetLayoutsMeta.NumValues + customIndex
    C_EditMode.SetActiveLayout(activeIndex)

    if UIErrorsFrame then
        UIErrorsFrame:SetScale(2)
    end
    PlayInstallSound()
    self:Print("Imported Buff/Debuff and Objective Tracker Edit Mode layout.")
end
