View Single Post
04-08-12, 05:58 AM   #4
Lordyfrb
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 71
This should work for you, not tested as I dont use reflux or nibProfileLoader.
Lua Code:
  1. local frame = CreateFrame("FRAME");
  2.     frame:RegisterEvent("VARIABLES_LOADED");
  3.      
  4.     -- BEGIN USER OPTIONS --
  5.     -- InterfaceName = Name to describe your UI
  6.     -- ProfileName = Addon profile name to use with /reflux switch
  7.     local InterfaceName  = "MyInterface"
  8.     local TankName = "MyTankProfile"
  9.     local HealName = "MyHealProfile"
  10.      
  11.     local UseClassProfiles = false  -- Use specific profile names for different classes
  12.     local ClassProfiles = {         -- Change profile names to suit
  13.         ["DEATHKNIGHT"] = "MyProfile",
  14.         ["DRUID"] = "MyProfile",
  15.         ["HUNTER"] = "MyProfile",
  16.         ["MAGE"] = "MyProfile",
  17.         ["PALADIN"] = "MyProfile",
  18.         ["PRIEST"] = "MyProfile",
  19.         ["ROGUE"] = "MyProfile",
  20.         ["SHAMAN"] = "MyProfile",
  21.         ["WARLOCK"] = "MyProfile",
  22.         ["WARRIOR"] = "MyProfile",
  23.     }
  24.     -- END USER OPTIONS --
  25.      
  26.     local LocalizedMessages = {
  27.         ["enUS"] = {
  28.             [1] = "Thanks for using xxxx UI. Please select a UI layout from options below.",
  29.             [2] = "Tank",
  30.             [3] = "Heal",
  31.         },
  32.         ["deDE"] = {
  33.             [1] = "Neuen Character gefunden! Willst du die %s einstellungen laden?",
  34.             [2] = "Ja",
  35.             [3] = "Nein",
  36.         },
  37.     }
  38.      
  39.      
  40.     local CID, CE, HasAdded = "", false, false
  41.      
  42.     local function AddChar()
  43.       if (CID ~= "") and not HasAdded then
  44.         tinsert(nibPLNames, CID)
  45.         HasAdded = true
  46.       end
  47.     end
  48.      
  49.     local function CharAnswered(ans)
  50.       AddChar()
  51.       if ans == "Tank" then
  52.         local _, class = UnitClass("player")
  53.         local NewProfile = UseClassProfiles and ClassProfiles[class] or ProfileName
  54.         local RefluxArg = string.format("%s %s", "switch", TankProfile)
  55.         SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  56.       elseif ans == "Heal" then
  57.         local _, class = UnitClass("player")
  58.         local NewProfile = UseClassProfiles and ClassProfiles[class] or ProfileName
  59.         local RefluxArg = string.format("%s %s", "switch", HealProfile)
  60.         SlashCmdList.REFLUX(RefluxArg) -- This will cause a UI reload
  61.       end
  62.     end
  63.      
  64.     local function AskNewChar()
  65.       local Locale = GetLocale() or "enUS"
  66.       local MsgTexts = LocalizedMessages[Locale] or LocalizedMessages["enUS"]
  67.       StaticPopupDialogs["PUDASKNEWCHAR"] = {
  68.         text = MsgTexts[1],
  69.         button1 = MsgTexts[2],
  70.         button2 = MsgTexts[3],
  71.         OnAccept = function()
  72.           CharAnswered(Tank)
  73.         end,
  74.         OnCancel = function()
  75.           CharAnswered(Heal)
  76.         end,
  77.         timeout = 0,
  78.         whileDead = true,
  79.         hideOnEscape = false,
  80.         notClosableByLogout = true,
  81.       }
  82.       StaticPopup_Show ("PUDASKNEWCHAR", InterfaceName);
  83.     end
  84.      
  85.     local function CheckNewChar()
  86.       CID = string.format("%s - %s", GetRealmName(), UnitName("player"))
  87.       CE = false
  88.       if (nibPLNames == nil) then nibPLNames = { }; end
  89.       for i,v in pairs(nibPLNames) do
  90.         if (v == CID) then CE = true; end
  91.       end
  92.       if not CE then AskNewChar(); end
  93.     end
  94.      
  95.     local function eventHandler(self, event, ...)
  96.       if (event == "VARIABLES_LOADED") then
  97.         CheckNewChar()
  98.       end
  99.     end
  100.     frame:SetScript("OnEvent", eventHandler);
__________________
  Reply With Quote