Try this (just a slightly modified version of Phanx's code)
If it doesn't work, I'll have a look at a different solution over the next couple days.
Code:
local f = CreateFrame("Frame", "Raidstring", UIParent)
f:SetPoint("CENTER")
f:SetSize(400, 125)
f:Hide()
f:SetBackdrop({
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", tileSize = 32, tile = true,
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", edgeSize = 32,
insets = { left = 11, right = 12, top = 12, bottom = 11 }
})
f.Header = f:CreateTexture(nil, "ARTWORK")
f.Header:SetPoint("CENTER", f, "TOP")
f.Header:SetSize(139, 40)
f.Header:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
f.Header:SetTexCoord(58/256, 196/256, 0, 39/64)
f.HeaderText = f:CreateFontString(nil, "OVERLAY", "GameFontNormal")
f.HeaderText:SetPoint("CENTER", f.Header)
f.HeaderText:SetText("Raidstring")
f:EnableMouse(true)
f:SetMovable(true)
f.TitleRegion = f:CreateTitleRegion()
f.TitleRegion:SetAllPoints(f.Header)
f.EditBox = CreateFrame("EditBox", "$parentEditBox", f, "InputBoxTemplate")
f.EditBox:SetPoint("TOP", f.Header, "BOTTOM")
f.EditBox:SetSize(300, 16)
f.EditBox:SetAltArrowKeyMode(false)
f.EditBox:SetAutoFocus(false)
f.EditBox:SetFontObject(GameFontHighlightSmall)
f.EditBox:SetMaxLetters(0) -- no limit
f.EditBox:SetScript("OnEnterPressed", function(self)
f:Hide()
f:SortRaid(self:GetText())
end)
f.EditBox:SetScript("OnEscapePressed", function(self)
f:Hide()
end)
f.CloseButton = CreateFrame("Button", "$parentCloseButton", f, "OptionsButtonTemplate")
f.CloseButton:SetPoint("BOTTOM", 0, 20)
f.CloseButton:SetText(APPLY)
f.CloseButton:SetScript("OnClick", function()
f:Hide()
f:SortRaid(f.EditBox:GetText())
end)
f:SetScript("OnHide", function()
f.EditBox:ClearHistory()
end)
------------------------------------------------------------------------
local current, numInGroup = {}, {}
local function UpdateRaidState()
wipe(numInGroup)
wipe(current)
for i = 1, GetNumGroupMembers() do
local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
current[name] = { index = i, group = subgroup }
numInGroup[subgroup] = (numInGroup[subgroup] or 0) + 1
end
end
function f:SortRaid(str)
if not str or strlen(str) == 0 or not IsInRaid() then
return
end
if not UnitIsGroupLeader("player") and not UnitIsGroupAssistant("player") then
return DEFAULT_CHAT_FRAME:AddMessage(format("%sRaidString:|r %s", NORMAL_FONT_COLOR_CODE, "You must be raid leader or promoted to sort the raid!"))
end
-- Get a snapshot of the current raid layout:
UpdateRaidState()
local wanted = {}
-- Build a map of the desired raid layout:
for name, group in string.gmatch(str, "([^&:]+):(%d+)") do
-- Ignore named players not in the raid.
if current[name] then
wanted[name] = group
end
end
local dirty
-- Look for players not in the wanted group and move them:
for name, group in pairs(wanted) do
if current[name].group ~= group then
if numInGroup[group] then
if numInGroup[group] < 5 then
-- Just move them:
SetRaidSubgroup(current[name].index, group)
dirty = true
else
-- Look for someone to swap with:
for xname, xdata in pairs(current) do
if xdata.group == group and wanted[xname] ~= group then
-- Do the swap:
SwapRaidSubgroup(current[name].index, xdata.index)
dirty = true
end
end
end
else
SetRaidSubgroup(current[name].index, group)
dirty = true
end
end
if (dirty) then
UpdateRaidState()
dirty = nil
end
end
end
------------------------------------------------------------------------
SLASH_RAIDSTRING1 = "/rs"
SlashCmdList["RAIDSTRING"] = function()
if not IsInRaid() then
return
end
local name = UnitName("player")
local realm = GetRealmName()
local guild = IsInGuild and GetGuildInfo("player") or ""
local xml = "<RaidInfo><Info>Raidassist</Info><Password>W2Any"..realm.."dEAv"..name.."2AxaS</Password><Realm>"..realm.."</Realm><Guild>"..guild.."</Guild><Name>"..name.."</Name><PlayerInfos>"
for i = 1, GetNumGroupMembers() do
local localizedClass, englishClass = UnitClass("raid"..i)
local name, online = UnitName("raid"..i)
xml = xml.."<key"..i.."><name>"..name.."</name><class>"..englishClass.."</class></key"..i..">"
end
xml = xml.."</PlayerInfos></RaidInfo>"
f.EditBox:SetText(xml)
f.EditBox:HighlightText()
f:Show()
end
------------------------------------------------------------------------
SLASH_MAKERAID1 = "/rm"
SlashCmdList["MAKERAID"] = function()
f:Show()
end