This should work for you, not tested as I dont use reflux or nibProfileLoader.
Lua Code:
local frame = CreateFrame("FRAME");
frame:RegisterEvent("VARIABLES_LOADED");
-- BEGIN USER OPTIONS --
-- InterfaceName = Name to describe your UI
-- ProfileName = Addon profile name to use with /reflux switch
local InterfaceName = "MyInterface"
local TankName = "MyTankProfile"
local HealName = "MyHealProfile"
local UseClassProfiles = false -- Use specific profile names for different classes
local ClassProfiles = { -- Change profile names to suit
["DEATHKNIGHT"] = "MyProfile",
["DRUID"] = "MyProfile",
["HUNTER"] = "MyProfile",
["MAGE"] = "MyProfile",
["PALADIN"] = "MyProfile",
["PRIEST"] = "MyProfile",
["ROGUE"] = "MyProfile",
["SHAMAN"] = "MyProfile",
["WARLOCK"] = "MyProfile",
["WARRIOR"] = "MyProfile",
}
-- END USER OPTIONS --
local LocalizedMessages = {
["enUS"] = {
[1] = "Thanks for using xxxx UI. Please select a UI layout from options below.",
[2] = "Tank",
[3] = "Heal",
},
["deDE"] = {
[1] = "Neuen Character gefunden! Willst du die %s einstellungen laden?",
[2] = "Ja",
[3] = "Nein",
},
}
local CID, CE, HasAdded = "", false, false
local function AddChar()
if (CID ~= "") and not HasAdded then
tinsert(nibPLNames, CID)
HasAdded = true
end
end
local function CharAnswered(ans)
AddChar()
if ans == "Tank" then
local _, class = UnitClass("player")
local NewProfile = UseClassProfiles and ClassProfiles[class] or ProfileName
local RefluxArg = string.format("%s %s", "switch", TankProfile)
SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
elseif ans == "Heal" then
local _, class = UnitClass("player")
local NewProfile = UseClassProfiles and ClassProfiles[class] or ProfileName
local RefluxArg = string.format("%s %s", "switch", HealProfile)
SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
end
end
local function AskNewChar()
local Locale = GetLocale() or "enUS"
local MsgTexts = LocalizedMessages[Locale] or LocalizedMessages["enUS"]
StaticPopupDialogs["PUDASKNEWCHAR"] = {
text = MsgTexts[1],
button1 = MsgTexts[2],
button2 = MsgTexts[3],
OnAccept = function()
CharAnswered(Tank)
end,
OnCancel = function()
CharAnswered(Heal)
end,
timeout = 0,
whileDead = true,
hideOnEscape = false,
notClosableByLogout = true,
}
StaticPopup_Show ("PUDASKNEWCHAR", InterfaceName);
end
local function CheckNewChar()
CID = string.format("%s - %s", GetRealmName(), UnitName("player"))
CE = false
if (nibPLNames == nil) then nibPLNames = { }; end
for i,v in pairs(nibPLNames) do
if (v == CID) then CE = true; end
end
if not CE then AskNewChar(); end
end
local function eventHandler(self, event, ...)
if (event == "VARIABLES_LOADED") then
CheckNewChar()
end
end
frame:SetScript("OnEvent", eventHandler);