Files
2026-11-15 17:40:50 +01:00

460 lines
18 KiB
Lua

---
--- AtlasUI.lua - Atlas main UI frame and interface components
---
--- This file contains the main UI frame creation and management for Atlas-CFM.
--- It handles the primary Atlas window, frame positioning, event registration,
--- and provides the foundation for all Atlas UI components and interactions.
---
--- Features:
--- - Main Atlas frame creation and configuration
--- - Frame positioning and movement handling
--- - Event registration and handling
--- - UI component initialization
--- - Frame visibility and state management
---
--- @compatible World of Warcraft 1.12
---
local _G = getfenv()
AtlasCFM = _G.AtlasCFM
local Colors = AtlasCFM.Colors
local L = AtlasCFM.Localization.UI
do
-- Create the main Atlas frame
local atlasFrame = CreateFrame("Frame", "AtlasCFMFrame", UIParent)
atlasFrame:SetFrameStrata("HIGH")
atlasFrame:SetWidth(921)
atlasFrame:SetHeight(601)
atlasFrame:SetPoint("TOPLEFT", 0, -104)
atlasFrame:Hide()
atlasFrame:SetMovable(true)
atlasFrame:EnableMouse(true)
atlasFrame:RegisterForDrag("LeftButton")
atlasFrame:RegisterEvent("ADDON_LOADED")
atlasFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
-- Scripts
atlasFrame:SetScript("OnEvent", function()
AtlasCFM.OnEvent()
end)
atlasFrame:SetScript("OnShow", function()
AtlasCFM.OnShow()
end)
atlasFrame:SetScript("OnHide", function()
atlasFrame:StopMovingOrSizing()
atlasFrame.isMoving = false
-- Persist state (Last Opened Page)
-- Check if LootFrame is active (IsShown returns true if Show() was called, even if parent hidden)
if AtlasCFMLootItemsFrame and AtlasCFMLootItemsFrame:IsShown() and AtlasCFMLootItemsFrame.StoredElement then
if not AtlasCFMCharDB.LastOpened then AtlasCFMCharDB.LastOpened = {} end
AtlasCFMCharDB.LastOpened.StoredElement = AtlasCFMLootItemsFrame.StoredElement
AtlasCFMCharDB.LastOpened.StoredMenu = AtlasCFMLootItemsFrame.StoredMenu
if AtlasCFMOptions then
AtlasCFMCharDB.LastOpened.AtlasType = AtlasCFMOptions.AtlasType
AtlasCFMCharDB.LastOpened.AtlasZone = AtlasCFMOptions.AtlasZone
end
else
-- Clear if we are not on a loot page to avoid restoring old state when user consciously closed it
if AtlasCFMCharDB and AtlasCFMCharDB.LastOpened then
AtlasCFMCharDB.LastOpened = nil
end
end
end)
atlasFrame:SetScript("OnDragStart", function()
AtlasCFM.StartMoving()
end)
atlasFrame:SetScript("OnDragStop", function()
atlasFrame:StopMovingOrSizing()
atlasFrame.isMoving = false
end)
atlasFrame:SetScript("OnMouseUp", function()
atlasFrame:StopMovingOrSizing()
atlasFrame.isMoving = false
AtlasCFM.OnClick()
end)
--Allows Atlas to be closed with the Escape key
tinsert(UISpecialFrames, "AtlasCFMFrame")
--Setting up slash commands involves referencing some strage auto-generated variables
SLASH_AtlasCFM1 = "/AtlasCFM"
SlashCmdList["AtlasCFM"] = AtlasCFM.SlashCommand
-- Close button
local closeButton = CreateFrame("Button", "AtlasCFMCloseButton", atlasFrame, "UIPanelCloseButton")
closeButton:SetPoint("TOPRIGHT", 5, -7)
-- Lock button
local lockButton = CreateFrame("Button", "AtlasCFMLockButton", atlasFrame)
lockButton:SetWidth(32)
lockButton:SetHeight(32)
lockButton:SetPoint("RIGHT", closeButton, "LEFT", 10, 0)
lockButton:SetScript("OnClick", function()
AtlasCFM.ToggleLock()
end)
-- Create the main textures
local lockNorm = lockButton:CreateTexture("AtlasCFMLockNorm", "BORDER")
lockButton:SetNormalTexture(lockNorm)
lockNorm:SetAllPoints(lockButton)
local lockPush = lockButton:CreateTexture("AtlasCFMLockPush", "BORDER")
lockButton:SetPushedTexture(lockPush)
lockPush:SetAllPoints(lockButton)
local lockHighlight = lockButton:CreateTexture(nil, "HIGHLIGHT")
lockHighlight:SetTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Highlight")
lockHighlight:SetBlendMode("ADD")
lockHighlight:SetAllPoints(lockButton)
lockButton:SetHighlightTexture(lockHighlight)
-- Type dropdown (Hewdrop-based)
local dropDownType = CreateFrame("Button", "AtlasCFMFrameDropDownType", atlasFrame)
dropDownType:SetWidth(210)
dropDownType:SetHeight(24)
dropDownType:SetPoint("TOPLEFT", 80, -55)
-- Background texture for dropdown button
local dropDownTypeBg = dropDownType:CreateTexture(nil, "BACKGROUND")
dropDownTypeBg:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
dropDownTypeBg:SetVertexColor(0.1, 0.1, 0.1, 0.8)
dropDownTypeBg:SetAllPoints(dropDownType)
-- Text display for current selection
local dropDownTypeText = dropDownType:CreateFontString("AtlasCFMFrameDropDownTypeText", "OVERLAY",
"GameFontHighlightSmall")
dropDownTypeText:SetPoint("LEFT", dropDownType, "LEFT", 8, 0)
dropDownTypeText:SetPoint("RIGHT", dropDownType, "RIGHT", -20, 0)
dropDownTypeText:SetJustifyH("LEFT")
-- Arrow texture
local dropDownTypeArrow = dropDownType:CreateTexture(nil, "OVERLAY")
dropDownTypeArrow:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
dropDownTypeArrow:SetWidth(16)
dropDownTypeArrow:SetHeight(16)
dropDownTypeArrow:SetPoint("RIGHT", dropDownType, "RIGHT", -2, 0)
-- Highlight texture
local dropDownTypeHighlight = dropDownType:CreateTexture(nil, "HIGHLIGHT")
dropDownTypeHighlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
dropDownTypeHighlight:SetBlendMode("ADD")
dropDownTypeHighlight:SetAllPoints(dropDownType)
-- Label above dropdown
local dropDownTypeLabel = dropDownType:CreateFontString("AtlasCFMFrameDropDownTypeLabel", "BACKGROUND",
"GameFontNormalSmall")
dropDownTypeLabel:SetText(L["Select Category"])
dropDownTypeLabel:SetPoint("BOTTOMLEFT", dropDownType, "TOPLEFT", 0, 2)
-- OnClick to open Hewdrop menu
dropDownType:SetScript("OnClick", function()
if AtlasCFM.HewdropMenus:IsOpen(dropDownType) then
AtlasCFM.HewdropMenus:Close()
else
AtlasCFM.HewdropMenus:Close()
AtlasCFM.HewdropMenus:OpenCategoryMenu(dropDownType)
end
end)
-- Map dropdown (Hewdrop-based)
local dropDown = CreateFrame("Button", "AtlasCFMFrameDropDown", atlasFrame)
dropDown:SetWidth(210)
dropDown:SetHeight(24)
dropDown:SetPoint("LEFT", dropDownType, "RIGHT", 10, 0)
-- Background texture
local dropDownBg = dropDown:CreateTexture(nil, "BACKGROUND")
dropDownBg:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
dropDownBg:SetVertexColor(0.1, 0.1, 0.1, 0.8)
dropDownBg:SetAllPoints(dropDown)
-- Text display for current selection
local dropDownText = dropDown:CreateFontString("AtlasCFMFrameDropDownText", "OVERLAY", "GameFontHighlightSmall")
dropDownText:SetPoint("LEFT", dropDown, "LEFT", 8, 0)
dropDownText:SetPoint("RIGHT", dropDown, "RIGHT", -20, 0)
dropDownText:SetJustifyH("LEFT")
-- Arrow texture
local dropDownArrow = dropDown:CreateTexture(nil, "OVERLAY")
dropDownArrow:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
dropDownArrow:SetWidth(16)
dropDownArrow:SetHeight(16)
dropDownArrow:SetPoint("RIGHT", dropDown, "RIGHT", -2, 0)
-- Highlight texture
local dropDownHighlight = dropDown:CreateTexture(nil, "HIGHLIGHT")
dropDownHighlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
dropDownHighlight:SetBlendMode("ADD")
dropDownHighlight:SetAllPoints(dropDown)
-- Label above dropdown
local dropDownLabel = dropDown:CreateFontString("AtlasCFMFrameDropDownLabel", "BACKGROUND", "GameFontNormalSmall")
dropDownLabel:SetText(L["Select Map"])
dropDownLabel:SetPoint("BOTTOMLEFT", dropDown, "TOPLEFT", 0, 2)
-- OnClick to open Hewdrop menu
dropDown:SetScript("OnClick", function()
if AtlasCFM.HewdropMenus:IsOpen(dropDown) then
AtlasCFM.HewdropMenus:Close()
else
AtlasCFM.HewdropMenus:Close()
AtlasCFM.HewdropMenus:OpenInstanceMenu(dropDown)
end
end)
-- Search box
local searchBox = CreateFrame("EditBox", "AtlasCFMSearchEditBox", atlasFrame, "InputBoxTemplate")
searchBox:SetWidth(132)
searchBox:SetHeight(32)
searchBox:SetPoint("BOTTOMRIGHT", -160, 15)
searchBox:SetMaxLetters(80)
searchBox:SetAutoFocus(false)
searchBox:SetTextInsets(0, 8, 0, 0)
searchBox:SetScript("OnEnterPressed", function()
AtlasCFM.Search(this:GetText())
this:ClearFocus()
AtlasCFM.LootBrowserUI.ScrollBarUpdate()
end)
-- Switch dropdown is now handled by Hewdrop in AtlasCFM.SwitchButtonOnClick()
-- Switch button
local switchButton = CreateFrame("Button", "AtlasCFMSwitchButton", searchBox, "OptionsButtonTemplate")
switchButton:SetWidth(80)
switchButton:SetHeight(20)
switchButton:SetPoint("RIGHT", searchBox, "LEFT", -6, 0)
switchButton:SetScript("OnClick", function()
AtlasCFM.SwitchButtonOnClick()
end)
-- Search button
local searchButton = CreateFrame("Button", nil, searchBox, "OptionsButtonTemplate")
searchButton:SetWidth(70)
searchButton:SetPoint("LEFT", searchBox, "RIGHT", 1, 0)
searchButton:SetText(L["Search"])
searchButton:SetScript("OnClick", function()
AtlasCFM.Search(AtlasCFMSearchEditBox:GetText())
AtlasCFMSearchEditBox:ClearFocus()
AtlasCFM.LootBrowserUI.ScrollBarUpdate()
end)
-- Clear button
local clearButton = CreateFrame("Button", nil, searchBox, "OptionsButtonTemplate")
clearButton:SetWidth(70)
clearButton:SetPoint("LEFT", searchButton, "RIGHT", 0, 0)
clearButton:SetText(L["Clear"])
clearButton:SetScript("OnClick", function()
AtlasCFMSearchEditBox:SetText("")
AtlasCFM.Search(AtlasCFMSearchEditBox:GetText())
AtlasCFMSearchEditBox:ClearFocus()
AtlasCFM.LootBrowserUI.ScrollBarUpdate()
end)
-- Options button
local optionsButton = CreateFrame("Button", nil, atlasFrame, "OptionsButtonTemplate")
optionsButton:SetWidth(80)
optionsButton:SetPoint("TOPRIGHT", -10, -60)
optionsButton:SetText(L["Options"])
optionsButton:SetScript("OnClick", function()
AtlasCFM.OptionsOnClick()
end)
-- Hide Quests button
local questsToggleButton = CreateFrame("Button", nil, atlasFrame, "OptionsButtonTemplate")
questsToggleButton:SetPoint("LEFT", optionsButton, -90, 0)
questsToggleButton:SetText(L["Quests"])
questsToggleButton:SetScript("OnClick", function()
AtlasCFM.Quest.ToggleQuestFrame()
end)
-- Hide Loot Panel button
local ShowPanelButton = CreateFrame("Button", nil, atlasFrame, "OptionsButtonTemplate")
ShowPanelButton:SetText(L["Loot Panel"])
ShowPanelButton:SetPoint("LEFT", questsToggleButton, -90, 0)
ShowPanelButton:SetScript("OnClick", function()
AtlasCFM.OptionShowPanelOnClick()
end)
-- Loot Filter button
local filterButton = CreateFrame("Button", "AtlasCFMLootFilterButton", atlasFrame, "OptionsButtonTemplate")
filterButton:SetWidth(130)
filterButton:SetPoint("LEFT", ShowPanelButton, -130, 0)
filterButton:SetScript("OnClick", function()
AtlasCFM.OptionFilterModeOnClick()
end)
-- Scroll frame
local scrollBar = CreateFrame("ScrollFrame", "AtlasCFMScrollBar", atlasFrame, "FauxScrollFrameTemplate")
scrollBar:SetWidth(351)
scrollBar:SetHeight(367)
scrollBar:SetPoint("TOPLEFT", 530, -186)
scrollBar:SetScript("OnVerticalScroll", function()
FauxScrollFrame_OnVerticalScroll(15, AtlasCFM.LootBrowserUI.ScrollBarUpdate)
end)
scrollBar:SetScript("OnShow", function()
AtlasCFM.LootBrowserUI.ScrollBarUpdate()
end)
-- Search container
local noSearch = atlasFrame:CreateFontString("AtlasCFMNoSearch", "ARTWORK", "GameFontDisableSmall")
noSearch:SetText(L["Search Unavailable"])
noSearch:SetPoint("TOPLEFT", 540, -555)
noSearch:SetTextColor(1, 1, 1, 0.4)
local zoneText = atlasFrame:CreateFontString("AtlasCFMZoneText", "OVERLAY", "GameFontHighlightLarge")
zoneText:SetWidth(295)
zoneText:SetHeight(20)
zoneText:SetAlpha(.8)
zoneText:SetPoint("TOPLEFT", 546, -95)
zoneText:SetJustifyH("LEFT")
local locationText = atlasFrame:CreateFontString("AtlasCFMLocationText", "OVERLAY", "GameFontNormal")
locationText:SetWidth(188)
locationText:SetHeight(15)
locationText:SetPoint("TOPLEFT", zoneText, 0, -18)
locationText:SetJustifyH("LEFT")
local levelRangeText = atlasFrame:CreateFontString("AtlasCFMLevelRangeText", "OVERLAY", "GameFontNormal")
levelRangeText:SetWidth(200)
levelRangeText:SetHeight(15)
levelRangeText:SetPoint("TOPLEFT", zoneText, 0, -30)
levelRangeText:SetJustifyH("LEFT")
local playerLimitText = atlasFrame:CreateFontString("AtlasCFMPlayerLimitText", "OVERLAY", "GameFontNormal")
playerLimitText:SetWidth(200)
playerLimitText:SetHeight(15)
playerLimitText:SetPoint("TOPLEFT", zoneText, 0, -42)
playerLimitText:SetJustifyH("LEFT")
local attunText = atlasFrame:CreateFontString("AtlasCFMAttunText", "OVERLAY", "GameFontNormal")
attunText:SetWidth(130)
attunText:SetHeight(15)
attunText:SetPoint("TOPLEFT", zoneText, 0, -54)
attunText:SetJustifyH("LEFT")
local damageTypeText = atlasFrame:CreateFontString("AtlasCFMDamageTypeText", "OVERLAY", "GameFontNormal")
damageTypeText:SetWidth(300)
damageTypeText:SetHeight(15)
damageTypeText:SetPoint("TOPLEFT", zoneText, 0, -67)
damageTypeText:SetJustifyH("LEFT")
local entranceText = atlasFrame:CreateFontString("AtlasCFMTextentr", "OVERLAY", "GameFontNormal")
entranceText:SetWidth(70)
entranceText:SetHeight(15)
entranceText:SetPoint("TOPLEFT", zoneText, 295, 0)
entranceText:SetJustifyH("LEFT")
local entrance1Text = atlasFrame:CreateFontString("AtlasCFMTextentr1", "OVERLAY", "GameFontNormal")
entrance1Text:SetWidth(168)
entrance1Text:SetHeight(15)
entrance1Text:SetPoint("TOPLEFT", zoneText, 190, -21)
entrance1Text:SetJustifyH("LEFT")
local entrance2Text = atlasFrame:CreateFontString("AtlasCFMTextentr2", "OVERLAY", "GameFontNormal")
entrance2Text:SetWidth(168)
entrance2Text:SetHeight(15)
entrance2Text:SetPoint("TOPLEFT", zoneText, 190, -32)
entrance2Text:SetJustifyH("LEFT")
local entrance3Text = atlasFrame:CreateFontString("AtlasCFMTextentr3", "OVERLAY", "GameFontNormal")
entrance3Text:SetWidth(168)
entrance3Text:SetHeight(15)
entrance3Text:SetPoint("TOPLEFT", zoneText, 190, -44)
entrance3Text:SetJustifyH("LEFT")
local entrance4Text = atlasFrame:CreateFontString("AtlasCFMTextentr4", "OVERLAY", "GameFontNormal")
entrance4Text:SetWidth(168)
entrance4Text:SetHeight(15)
entrance4Text:SetPoint("TOPLEFT", zoneText, 190, -56)
entrance4Text:SetJustifyH("LEFT")
local entrance5Text = atlasFrame:CreateFontString("AtlasCFMTextentr5", "OVERLAY", "GameFontNormal")
entrance5Text:SetWidth(168)
entrance5Text:SetHeight(15)
entrance5Text:SetPoint("TOPLEFT", zoneText, 190, -68)
entrance5Text:SetJustifyH("LEFT")
-- Instance Type Icon Button (Dungeon/Raid)
local instanceTypeButton = CreateFrame("Button", "AtlasCFMInstanceTypeButton", atlasFrame)
instanceTypeButton:SetWidth(30)
instanceTypeButton:SetHeight(30)
instanceTypeButton:SetPoint("RIGHT", entranceText, "LEFT")
instanceTypeButton:EnableMouse(true)
local instanceTypeTexture = instanceTypeButton:CreateTexture("AtlasCFMInstanceTypeIcon", "ARTWORK")
instanceTypeTexture:SetAllPoints()
instanceTypeButton:SetNormalTexture(instanceTypeTexture)
instanceTypeButton:Hide()
instanceTypeButton:SetScript("OnEnter", function()
this:SetWidth(34)
this:SetHeight(34)
if this.tooltipText then
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:SetText(this.tooltipText)
GameTooltip:Show()
end
end)
instanceTypeButton:SetScript("OnLeave", function()
this:SetWidth(30)
this:SetHeight(30)
GameTooltip:Hide()
end)
instanceTypeButton:SetScript("OnClick", function()
AtlasCFM.OnInstanceTypeClick()
end)
-- Textures
local topTexture = atlasFrame:CreateTexture("AtlasCFMFrameTop", "ARTWORK")
topTexture:SetTexture(AtlasCFM.PATH .. "Images\\Frame-Top")
topTexture:SetVertexColor(0.80, 0.60, 0.25)
topTexture:SetWidth(512)
topTexture:SetHeight(128)
topTexture:SetPoint("TOPLEFT", 0, 0)
local leftTexture = atlasFrame:CreateTexture("AtlasCFMFrameLeft", "ARTWORK")
leftTexture:SetTexture(AtlasCFM.PATH .. "Images\\Frame-Left")
leftTexture:SetVertexColor(0.80, 0.60, 0.25)
leftTexture:SetWidth(32)
leftTexture:SetHeight(256)
leftTexture:SetPoint("TOPLEFT", 0, -128)
local bottomTexture = atlasFrame:CreateTexture("AtlasCFMFrameBottom", "ARTWORK")
bottomTexture:SetTexture(AtlasCFM.PATH .. "Images\\Frame-Bottom")
bottomTexture:SetVertexColor(0.80, 0.60, 0.25)
bottomTexture:SetWidth(512)
bottomTexture:SetHeight(256)
bottomTexture:SetPoint("TOPLEFT", 0, -384)
local bottom2Texture = atlasFrame:CreateTexture("AtlasCFMFrameBottom2", "ARTWORK")
bottom2Texture:SetTexture(AtlasCFM.PATH .. "Images\\Frame-Bottom2")
bottom2Texture:SetVertexColor(0.80, 0.60, 0.25)
bottom2Texture:SetWidth(512)
bottom2Texture:SetHeight(128)
bottom2Texture:SetPoint("TOPLEFT", 512, -512)
local rightTexture = atlasFrame:CreateTexture("AtlasCFMFrameRight", "ARTWORK")
rightTexture:SetTexture(AtlasCFM.PATH .. "Images\\Frame-Right")
rightTexture:SetVertexColor(0.80, 0.60, 0.25)
rightTexture:SetWidth(512)
rightTexture:SetHeight(512)
rightTexture:SetPoint("TOPLEFT", 512, 0)
local titleText = atlasFrame:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
titleText:SetText(Colors.YELLOW .. AtlasCFM.Name)
titleText:SetPoint("TOP", atlasFrame, "TOP", 0, -17)
local versionText = atlasFrame:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
versionText:SetText(AtlasCFM.Version)
versionText:SetTextColor(0.4, 0.4, 0.4)
versionText:SetPoint("TOPRIGHT", -52, -17)
-- Map texture
atlasFrame:CreateTexture("AtlasCFMMap", "BACKGROUND")
AtlasCFMMap:SetWidth(512)
AtlasCFMMap:SetHeight(512)
AtlasCFMMap:SetPoint("TOPLEFT", 18, -84)
end