local frame = CreateFrame("FRAME"); |
frame:RegisterEvent("VARIABLES_LOADED"); |
|
-- Changes by Valixx, please refer to the changelog on wowinterface.com. |
|
-- BEGIN USER OPTIONS -- |
-- ############################################################################################################################### |
|
-- Change "MyInterface" to your Interface Name. You can be creative, e.g. "JohnRamboUI" or "TheCrazyOneUI". Really? TheCrazyOne? |
local InterfaceName = "MyInterface" |
|
-- Change here the name you given your save in-game with the /reflux create or /reflux snapshot command. e.g. "/reflux create Madprofessor", then change "MyProfile" to "Madprofessor". |
local ProfileName = "MyProfile" |
|
-- Use specific profile names for different classes |
local UseClassProfiles = false |
|
-- Change profile names to suit your preferences. This below is not working unless you set the "local UseClassProfiles" above to true! |
local ClassProfiles = { |
["DEATHKNIGHT"] = "MyProfile", |
["DRUID"] = "MyProfile", |
["HUNTER"] = "MyProfile", |
["MONK"] = "MyProfile", |
["MAGE"] = "MyProfile", |
["PALADIN"] = "MyProfile", |
["PRIEST"] = "MyProfile", |
["ROGUE"] = "MyProfile", |
["SHAMAN"] = "MyProfile", |
["WARLOCK"] = "MyProfile", |
["WARRIOR"] = "MyProfile", |
} |
|
-- ############################################################################################################################### |
-- END USER OPTIONS -- |
|
local LocalizedMessages = { |
["enUS"] = { |
[1] = "New character detected! Do you wish to load the settings for %s?", |
[2] = "Yes", |
[3] = "No", |
}, |
["deDE"] = { |
[1] = "Neuen Character gefunden! Willst du die %s einstellungen laden?", |
[2] = "Ja", |
[3] = "Nein", |
}, |
["frFR"] = { |
[1] = "Nouveaux caractère trouvé! Vous-voulez chargez les paramètres pour %s?", |
[2] = "Oui", |
[3] = "Non", |
}, |
["ruRU"] = { |
[1] = "Novyy personazh obnaruzhen! Vy khotite, chtoby zagruzit' nastroyki dlya %s?", |
[2] = "Da", |
[3] = "Net", |
}, |
["esES"] = { |
[1] = "Nuevo personaje detecta! ¿Desea cargar los ajustes para %s?", |
[2] = "SÃ!", |
[3] = "No!", |
} |
} |
|
|
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 then |
local _, class = UnitClass("player") |
local NewProfile = UseClassProfiles and ClassProfiles[class] or ProfileName |
local RefluxArg = string.format("%s %s", "switch", NewProfile) |
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(true) |
end, |
OnCancel = function() |
CharAnswered(false) |
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); |