diff --git a/env/profiles.lua b/env/profiles.lua index c8cd667a..b99a0336 100644 --- a/env/profiles.lua +++ b/env/profiles.lua @@ -909,6 +909,30 @@ pfUI_profiles["Legacy"] = legacy pfUI_profiles["Adapta"] = adapta pfUI_profiles["Slim"] = slim +-- Default positions for new modules per profile. +-- These are applied during firstrun so frames don't spawn in the center of screen. +pfUI_profiles["Modern"].new_module_positions = { + pfSwingTimerMainhand = { anchor = "BOTTOM", parent = "UIParent", xpos = -179, ypos = 91 }, + pfSwingTimerRanged = { anchor = "BOTTOM", parent = "UIParent", xpos = -179, ypos = 71 }, + pfMarkTracking = { anchor = "LEFT", parent = "UIParent", xpos = 4, ypos = 17 }, +} +pfUI_profiles["Nostalgia"].new_module_positions = { + pfSwingTimerMainhand = { anchor = "BOTTOM", parent = "UIParent", xpos = -295, ypos = 88 }, + pfSwingTimerRanged = { anchor = "BOTTOM", parent = "UIParent", xpos = -295, ypos = 68 }, + pfMarkTracking = { anchor = "LEFT", parent = "UIParent", xpos = 6, ypos = -19 }, +} +pfUI_profiles["Legacy"].new_module_positions = { + pfSwingTimerMainhand = { anchor = "BOTTOM", parent = "UIParent", xpos = 0, ypos = 248 }, + pfSwingTimerRanged = { anchor = "BOTTOM", parent = "UIParent", xpos = 0, ypos = 228 }, + pfMarkTracking = { anchor = "LEFT", parent = "UIParent", xpos = 4, ypos = -17 }, +} +pfUI_profiles["Slim"].new_module_positions = { + pfSwingTimerMainhand = { anchor = "BOTTOM", parent = "UIParent", xpos = -186, ypos = 92 }, + pfSwingTimerRanged = { anchor = "BOTTOM", parent = "UIParent", xpos = -186, ypos = 72 }, + pfMarkTracking = { anchor = "LEFT", parent = "UIParent", xpos = 2, ypos = -82 }, +} +pfUI_profiles["Adapta"].new_module_positions = pfUI_profiles["Modern"].new_module_positions + -- overwrite core profiles in userdata local profile_loader = CreateFrame("Frame") diff --git a/modules/firstrun.lua b/modules/firstrun.lua index f27bd7f2..c4f1379c 100644 --- a/modules/firstrun.lua +++ b/modules/firstrun.lua @@ -139,6 +139,7 @@ pfUI:RegisterModule("firstrun", "vanilla:tbc", function () f.Modern:SetText("Modern") f.Modern:SetScript("OnClick", function() _G["pfUI_config"] = CopyTable(pfUI_profiles["Modern"]) + pfUI_init.selected_profile = "Modern" pfUI:LoadConfig() ReloadUI() end) @@ -152,6 +153,7 @@ pfUI:RegisterModule("firstrun", "vanilla:tbc", function () f.Nostalgia:SetText("Nostalgia") f.Nostalgia:SetScript("OnClick", function() _G["pfUI_config"] = CopyTable(pfUI_profiles["Nostalgia"]) + pfUI_init.selected_profile = "Nostalgia" pfUI:LoadConfig() ReloadUI() end) @@ -165,6 +167,7 @@ pfUI:RegisterModule("firstrun", "vanilla:tbc", function () f.Legacy:SetText("Legacy") f.Legacy:SetScript("OnClick", function() _G["pfUI_config"] = CopyTable(pfUI_profiles["Legacy"]) + pfUI_init.selected_profile = "Legacy" pfUI:LoadConfig() ReloadUI() end) @@ -178,6 +181,7 @@ pfUI:RegisterModule("firstrun", "vanilla:tbc", function () f.Slim:SetText("Slim") f.Slim:SetScript("OnClick", function() _G["pfUI_config"] = CopyTable(pfUI_profiles["Slim"]) + pfUI_init.selected_profile = "Slim" pfUI:LoadConfig() ReloadUI() end) @@ -307,6 +311,26 @@ pfUI:RegisterModule("firstrun", "vanilla:tbc", function () -- finalize dialog pfUI.firstrun:AddStep("finalize", function() + -- Set default positions for new modules based on the active profile. + -- Only write positions that haven't been saved yet (don't override user preferences). + local function SetDefaultPosition(name, anchor, xpos, ypos) + if not pfUI_config.position[name] then + pfUI_config.position[name] = { + anchor = anchor, + parent = "UIParent", + xpos = xpos, + ypos = ypos, + } + end + end + + local positions = (pfUI_profiles[pfUI_init.selected_profile or "Modern"] or pfUI_profiles["Modern"]).new_module_positions + or pfUI_profiles["Modern"].new_module_positions + + for frameName, pos in pairs(positions) do + SetDefaultPosition(frameName, pos.anchor, pos.xpos, pos.ypos) + end + local f = CreateFirstRunPage() f.text:SetText(T["Your interface is now set up.\n\nFor advanced configuration, just open the |cff33ffccpf|rUI settings via the escape menu or type \"|cffffffaa/pfui|r\" into the chat.\n\n Have a nice trip!\n\n|cffaaaaaa- Shagu"]) return f diff --git a/modules/marktracking.lua b/modules/marktracking.lua index f14e8f88..ddd8e532 100644 --- a/modules/marktracking.lua +++ b/modules/marktracking.lua @@ -1,3 +1,4 @@ +pfUI:RegisterNewModule("marktracking", "Mark Tracker") pfUI:RegisterModule("marktracking", "vanilla:tbc", function () -- Requires mark1-mark8 unit tokens (Turtle WoW / Nampower) if not UnitExists("mark1") and not UnitExists("mark8") then @@ -94,9 +95,9 @@ pfUI:RegisterModule("marktracking", "vanilla:tbc", function () pfUI.marktracking = CreateFrame("Frame", "pfMarkTracking", UIParent) pfUI.marktracking:SetFrameStrata("MEDIUM") if GROW == "up" then - pfUI.marktracking:SetPoint("BOTTOM", UIParent, "CENTER", 0, 0) + pfUI.marktracking:SetPoint("LEFT", UIParent, "LEFT", 6, -5) else - pfUI.marktracking:SetPoint("TOP", UIParent, "CENTER", 0, 0) + pfUI.marktracking:SetPoint("LEFT", UIParent, "LEFT", 6, -5) end pfUI.marktracking:SetWidth(TOTAL_ROW_WIDTH) pfUI.marktracking:SetHeight(8 * (ROW_HEIGHT + 1) + border * 2 - 1) diff --git a/modules/swingtimer.lua b/modules/swingtimer.lua index f7cd0a01..d5187fd1 100644 --- a/modules/swingtimer.lua +++ b/modules/swingtimer.lua @@ -1,3 +1,4 @@ +pfUI:RegisterNewModule("swingtimer", "Swing Timer") pfUI:RegisterModule("swingtimer", "vanilla:tbc", function () local rawborder, border = GetBorderSize() @@ -102,7 +103,7 @@ pfUI:RegisterModule("swingtimer", "vanilla:tbc", function () -- Mainhand bar pfUI.swingtimer.mainhand = CreateFrame("StatusBar", "pfSwingTimerMainhand", UIParent) - pfUI.swingtimer.mainhand:SetPoint("CENTER", UIParent, "CENTER", 0, -100) + pfUI.swingtimer.mainhand:SetPoint("BOTTOM", UIParent, "CENTER", -189, 103) pfUI.swingtimer.mainhand:SetWidth(sw_width) pfUI.swingtimer.mainhand:SetHeight(sw_height) pfUI.swingtimer.mainhand:SetMinMaxValues(0, 1) @@ -218,7 +219,7 @@ pfUI:RegisterModule("swingtimer", "vanilla:tbc", function () -- Ranged bar pfUI.swingtimer.ranged = CreateFrame("Frame", "pfSwingTimerRanged", UIParent) - pfUI.swingtimer.ranged:SetPoint("CENTER", UIParent, "CENTER", 0, -120) + pfUI.swingtimer.ranged:SetPoint("BOTTOM", UIParent, "CENTER", -189, 83) pfUI.swingtimer.ranged:SetWidth(sw_width) pfUI.swingtimer.ranged:SetHeight(sw_height) pfUI.swingtimer.ranged:Hide() diff --git a/pfUI.lua b/pfUI.lua index 6250cbff..5eda0491 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -253,6 +253,69 @@ function pfUI:GetEnvironment() return pfUI.env end +-- [ New Module Registry ] +-- Tracks modules introduced after initial release so existing users get +-- a one-time prompt asking if they want to enable them. +pfUI.new_modules = {} + +function pfUI:RegisterNewModule(name, label) + table.insert(pfUI.new_modules, { name = name, label = label }) +end + +function pfUI:CheckNewModules() + pfUI_init.seen_modules = pfUI_init.seen_modules or {} + + local pending = 0 + for _, entry in pairs(pfUI.new_modules) do + if not pfUI_init.seen_modules[entry.name] and pfUI_init["finalize"] then + pending = pending + 1 + end + end + + if pending == 0 then return end + + local remaining = pending + local needsReload = false + + local function onAnswer() + remaining = remaining - 1 + if remaining <= 0 and needsReload then + ReloadUI() + end + end + + for _, entry in pairs(pfUI.new_modules) do + local name = entry.name + if not pfUI_init.seen_modules[name] then + pfUI_init.seen_modules[name] = true + + -- Only prompt existing users (firstrun wizard already ran) + if pfUI_init["finalize"] then + StaticPopupDialogs["PFUI_NEW_MODULE_" .. strupper(name)] = { + text = "|cff33ffccpfUI|r: New module available!\n\n|cffffffffDo you want to enable |cff33ffcc" .. (entry.label or name) .. "|r|cffffffff?\n\nYou can always change this later in the pfUI settings.|r", + button1 = "Yes", + button2 = "No", + OnAccept = function() + pfUI_config["disabled"] = pfUI_config["disabled"] or {} + pfUI_config["disabled"][name] = nil + onAnswer() + end, + OnCancel = function() + pfUI_config["disabled"] = pfUI_config["disabled"] or {} + pfUI_config["disabled"][name] = "1" + needsReload = true + onAnswer() + end, + timeout = 0, + whileDead = true, + hideOnEscape = false, + } + StaticPopup_Show("PFUI_NEW_MODULE_" .. strupper(name)) + end + end + end +end + function pfUI:RegisterModule(name, a2, a3) if pfUI.module[name] then return end local hasv = type(a2) == "string" @@ -336,6 +399,9 @@ pfUI:SetScript("OnEvent", function() end pfUI.bootup = nil + + -- Prompt existing users about newly introduced modules + pfUI:CheckNewModules() end end)