09-03-12, 03:29 PM | #1 |
What does this function?
someone can tell me what this function does exactly?
Code:
function BlackList:GuildShare() local player = BlackList:GetPlayerByIndex(BlackList:GetSelectedBlackList()) SendAddonMessage("BlackList", format("%s#_#%s#_#%s#_#%s#_#%s#_#%s", player["name"], player["level"], player["class"], player["race"], player["reason"], player["realm"]), "GUILD") BlackList:AddMessage(format("Blacklist Data of \"%s\" send to Guild.", player["name"]), "yellow") return end |
|
09-03-12, 03:47 PM | #2 |
It sends a hidden addon message to all guild members running the addon with data of a certain player in the blacklist (including name, level, class, race, reason, realm). Then it adds a visible message to your chat frame stating that it did so.
Where it gets its data though is up to the rest of the addon. Why? |
|
09-03-12, 03:56 PM | #3 |
for the continuation of the code is
Code:
elseif (event == "CHAT_MSG_ADDON") then local prefix, message, distType, sender = ... if(prefix ~= "BlackList" or sender == UnitName("player") or message == nil) then return end local player, level, class, race, reason, realm = string.find(message, "(.*)#_#(.*)#_#(.*)#_#(.*)#_#(.*)#_#(.*)") if (BlackList:GetIndexByName(player, realm) > 0) then BlackList:AddPlayer(player, realm, reason, level, class, race) BlackList:AddMessage(format("Blacklist Data of \"%s\" received from %s.", player, sender), "yellow") end |
|
09-03-12, 05:27 PM | #4 |
Did you remember to register your frame for the CHAT_MSG_ADDON event?
As I've told you before, you really need to post all of your code if you want help with it. It's just a big waste of our time and yours if we have to guess about what's going on in the parts you didn't post. If you're working with someone else's addon, post both a link to the original addon, and full copies of each file you've modified.
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
09-03-12, 07:14 PM | #5 |
The addon is that originates
http://wow.curseforge.com/addons/bla...es/25-v-4-0-2/ I made a few edits to my native language, and according to some preferences, not changed anything in the function of sharing the database, but that is the only thing that is not working. Bindings.xml Code:
<Bindings> <Binding name="TOGGLE_BLACKLIST" header="BLACKLIST"> BlackList:ToggleTab() </Binding> </Bindings> Code:
BlackList = {} ESPARTANOS_BlackListedPlayers = {} BlackListOptions = {} BlackList.realm = GetRealmName() local BL_Blocked_Channels = {"SAY", "YELL", "WHISPER", "WHISPER_INFORM", "PARTY", "RAID", "RAID_WARNING", "EMOTE", "TEXT_EMOTE", "CHANNEL", "CHANNEL_JOIN", "CHANNEL_LEAVE"} local Already_Warned_For = {} Already_Warned_For["WHISPER"] = {} Already_Warned_For["TARGET"] = {} Already_Warned_For["PARTY_INVITE"] = {} Already_Warned_For["PARTY"] = {} Already_Warned_For["MOUSEOVER"] = {} Already_Warned_For["GUILD_ROSTER"] = {} local Orig_FriendsFrame_Update local Orig_ChatFrame_MessageEventHandler local BL_Default = { Sound = true, Center = true, Chat = true, Tooltip = true, MItem = true, } function BlackList:OnLoad() if (not ESPARTANOS_BlackListConfig) then ESPARTANOS_BlackListConfig = BL_Default end if ESPARTANOS_BlackListConfig.Sound == nil or "" then ESPARTANOS_BlackListConfig.Sound = true end if ESPARTANOS_BlackListConfig.Center == nil or "" then ESPARTANOS_BlackListConfig.Center = true end if ESPARTANOS_BlackListConfig.Chat == nil or "" then ESPARTANOS_BlackListConfig.Chat = true end if ESPARTANOS_BlackListConfig.Tooltip == nil or "" then ESPARTANOS_BlackListConfig.Tooltip = true end if ESPARTANOS_BlackListConfig.MItem == nil or "" then ESPARTANOS_BlackListConfig.MItem = true end BlackList:RegisterEvents() BlackList:HookFunctions() BlackList:RegisterSlashCmds() return end function BlackList:RegisterEvents() local frame = _G["BlackListTopFrame"] frame:RegisterEvent("VARIABLES_LOADED") frame:RegisterEvent("PLAYER_TARGET_CHANGED") frame:RegisterEvent("PARTY_INVITE_REQUEST") frame:RegisterEvent("PARTY_MEMBERS_CHANGED") frame:RegisterEvent("UPDATE_MOUSEOVER_UNIT") frame:RegisterEvent("WHO_LIST_UPDATE") frame:RegisterEvent("CHAT_MSG_SYSTEM") frame:RegisterEvent("CHAT_MSG_ADDON") frame:RegisterEvent("GUILD_ROSTER_UPDATE") frame:RegisterEvent("PLAYER_ENTERING_WORLD") frame:RegisterEvent("CHAT_MSG_WHISPER") return end function BlackList:AddMenuItems() UnitPopupButtons["AddToBl"] = { text = "Lista Negra", dist = 0, color = {r = 1.0, g = 0, b = 0} } hooksecurefunc("UnitPopup_OnClick", function(this) if (this.value == "AddToBl") then local dropdownMenu = _G["UIDROPDOWNMENU_INIT_MENU"] if(dropdownMenu.name ~= UnitName("player")) then BlackList:AddPlayer(dropdownMenu.name) end end end) tinsert(UnitPopupMenus["PLAYER"], (#UnitPopupMenus["PLAYER"])-1, "AddToBl") tinsert(UnitPopupMenus["PARTY"], (#UnitPopupMenus["PARTY"])-1, "AddToBl") tinsert(UnitPopupMenus["RAID_PLAYER"], (#UnitPopupMenus["RAID_PLAYER"])-1, "AddToBl") tinsert(UnitPopupMenus["CHAT_ROSTER"], (#UnitPopupMenus["CHAT_ROSTER"])-1, "AddToBl") tinsert(UnitPopupMenus["FRIEND"], (#UnitPopupMenus["FRIEND"])-1, "AddToBl") end function BlackList:HookFunctions() GameTooltip:HookScript("OnTooltipSetUnit", function(self) local name, unitid = self:GetUnit() if (not unitid) then unitid = "mouseover" end BlackList:TooltipInfo(self, unitid) end) end --[[hooksecurefunc("ChatFrame_MessageEventHandler", function(self, event, ...) local warnplayer, warnname = false, nil if (strsub(event, 1, 8) == "CHAT_MSG") then local _, name = ... if BlackList:GetIndexByName(name) == 0 then return end local chattype = string.sub(event, 10) for key, channel in pairs(BL_Blocked_Channels) do if (chattype == "WHISPER") then local alreadywarned = false for key, warnedname in pairs(Already_Warned_For["WHISPER"]) do if (name == warnedname) then alreadywarned = true end end if (not alreadywarned) then tinsert(Already_Warned_For["WHISPER"], name) warnplayer = true warnname = name end end end end if (warnplayer) then BlackList:AddMessage(warnname .. " est\195\161 em sua Lista Negra.", "red") end end)]] hooksecurefunc("FriendsFrame_Update", function(self) if (FriendsFrame.selectedTab == 1 and FriendsTabHeader.selectedTab == 4) then FriendsTabHeader:Show() FriendsFrameTitleText:SetText("Lista Negra") FriendsFrame_ShowSubFrame("BlackListFrame") BlackList:UpdateUI() end end) function BlackList:HandleSlashCmd(type, args) if (type == 1) then if (args == "") then BlackList:AddPlayer("target") else BlackList:AddPlayer(args) end end end function BlackList:HandleEvent(self, event, ...) local arg1 = ... if (event == "VARIABLES_LOADED") then if (ESPARTANOS_BlackListConfig.MItem == true) then BlackList:AddMenuItems() end if (ESPARTANOS_BlackListedPlayers[BlackList.realm]) then BlackList:Convert() return end if (not ESPARTANOS_BlackListedPlayers) then ESPARTANOS_BlackListedPlayers = {} end elseif (event == "PLAYER_ENTERING_WORLD") then BlackList:InsertUI() elseif (event == "CHAT_MSG_ADDON") then local prefix, message, distType, sender = ... if(prefix ~= "BlackList" or sender == UnitName("player") or message == nil) then return end local player, level, class, race, reason, realm = string.find(message, "(.*)#_#(.*)#_#(.*)#_#(.*)#_#(.*)#_#(.*)") if (BlackList:GetIndexByName(player, realm) > 0) then BlackList:AddPlayer(player, realm, reason, level, class, race) BlackList:AddMessage(format("Blacklist Data of \"%s\" received from %s.", player, sender), "yellow") end elseif (event == "PLAYER_TARGET_CHANGED") then if (not UnitIsPlayer("target")) then return end local name, realm = UnitName("target") if (BlackList:GetIndexByName(name) > 0) then local player = BlackList:GetPlayerByIndex(BlackList:GetIndexByName(name, realm)) local alreadywarned = false for warnedname, timepassed in pairs(Already_Warned_For["TARGET"]) do if ((name == warnedname) and (GetTime() < timepassed+10)) then alreadywarned = true end end if (not alreadywarned) then Already_Warned_For["TARGET"][name]=GetTime() BlackList:AddSound() BlackList:AddErrorMessage(name .. " est\195\161 em sua Lista Negra (seu alvo)", "red", 5) BlackList:AddMessage(name .. " est\195\161 em sua Lista Negra.", "yellow") end end elseif (event == "UPDATE_MOUSEOVER_UNIT") then local name, realm = UnitName("mouseover") local index = BlackList:GetIndexByName(name, realm) if (index > 0) then local player = BlackList:GetPlayerByIndex(index) local alreadywarned = false for warnedname, timepassed in pairs(Already_Warned_For["TARGET"]) do if ((name == warnedname) and (GetTime() < timepassed+10)) then alreadywarned = true end end if (not alreadywarned) then Already_Warned_For["TARGET"][name]=GetTime() BlackList:AddSound() BlackList:AddErrorMessage(name .. " est\195\161 em sua Lista Negra (detectado no mouse)", "red", 5) BlackList:AddMessage(name .. " est\195\161 em sua Lista Negra.", "red") local _, class = UnitClass("mouseover") local _, race = UnitRace("mouseover") BlackList:UpdateDetails(index, nil, nil, UnitLevel("mouseover"), class, race) end end elseif (event == "PARTY_INVITE_REQUEST") then local name = arg1 local index = BlackList:GetIndexByName(name) if (index > 0) then local player = BlackList:GetPlayerByIndex(index) local alreadywarned = false for warnedname, timepassed in pairs(Already_Warned_For["TARGET"]) do if ((name == warnedname) and (GetTime() < timepassed+10)) then alreadywarned = true end end if (not alreadywarned) then Already_Warned_For["TARGET"][name]=GetTime()+300 BlackList:AddSound() BlackList:AddErrorMessage(name .. " est\195\161 em sua Lista Negra (convidou para grupo).", "red", 10) end end elseif (event == "PARTY_MEMBERS_CHANGED") then for i = 0, GetNumPartyMembers(), 1 do local name, realm = UnitName("party" .. i) local index = BlackList:GetIndexByName(name, realm) if (index > 0) then local player = BlackList:GetPlayerByIndex(index) local alreadywarned = false for warnedname, timepassed in pairs(Already_Warned_For["TARGET"]) do if ((name == warnedname) and (GetTime() < timepassed+10)) then alreadywarned = true end end if (not alreadywarned) then Already_Warned_For["TARGET"][name]=GetTime()+300 BlackList:AddSound() BlackList:AddMessage(name .. " est\195\161 em sua Lista Negra (em seu grupo).", "red") end end end elseif (event == "WHO_LIST_UPDATE") then for i = 0, GetNumWhoResults(), 1 do local whoname, guild, level, race, class, zone, group = GetWhoInfo(i) if (BlackList:GetIndexByName(whoname) > 0) then BlackList:AddMessage(whoname .. " est\195\161 em sua Lista Negra (em sua pesquisa).", "red") end end elseif (event == "GUILD_ROSTER_UPDATE" and IsInGuild() ~= nil) then local bootNum = 0 for i = 0, GetNumGuildMembers(), 1 do local name, rank, rankIndex, level, classLocale, zone, note, officernote, online, status, class = GetGuildRosterInfo(i) local index = BlackList:GetIndexByName(name) if (index > 0) then local player = BlackList:GetPlayerByIndex(index) local alreadywarned = false for warnedname, timepassed in pairs(Already_Warned_For["GUILD_ROSTER"]) do if ((name == warnedname) and (GetTime() < timepassed+10)) then alreadywarned = true end end if (not alreadywarned) then Already_Warned_For["GUILD_ROSTER"][name]=GetTime()+0 BlackList:AddSound() BlackList:UpdateDetails(index, nil, nil, level, class, nil) BlackList:AddErrorMessage(name .. " est\195\161 em sua Lista Negra e est\195\161 na GUILDA.", "red", 5) BlackList:AddMessage(name .. " est\195\161 em sua Lista Negra e est\195\161 na GUILDA.", "red") if (CanGuildRemove() and BlackList:GetIndexByName(name) > 0) then GuildUninvite(name) end end end end elseif (event == "CHAT_MSG_SYSTEM" and arg1 ~= nil) then local whoname = string.match(arg1, "(%a+)", 10) if (BlackList:GetIndexByName(whoname) > 0) then BlackList:AddMessage(whoname .. " est\195\161 em sua Lista Negra.", "red") end elseif (event == "CHAT_MSG_WHISPER") then name, realm = select(6, GetPlayerInfoByGUID(select(12, ...))) if BlackList:GetIndexByName(name, realm) == 0 then return end local alreadywarned = false for key, warnedname in pairs(Already_Warned_For["WHISPER"]) do if (name == warnedname) then alreadywarned = true end end if (not alreadywarned) then tinsert(Already_Warned_For["WHISPER"], name) BlackList:AddMessage(name .. " est\195\161 em sua Lista Negra.", "red") end end end Code:
function BlackList:AddPlayer(player, realm, reason, level, class, race) local name, added if(string.find(player, "(.*)-(.*)") ~= nil) then _, _, player, realm = string.find(player, "(.*)-(.*)") end if (player == nil or player == "") then return end if(realm == nil and (player == UnitName("player") or UnitName("target") == UnitName("player"))) then return end if (player == "target" or player == UnitName("target")) then if UnitIsPlayer("target") then name, realm = UnitName("target") level = tostring(UnitLevel("target")) _, class = UnitClass("target") _, race = UnitRace("target") else StaticPopup_Show("BL_PLAYER") return end else name = player end if (BlackList:GetIndexByName(name, realm) > 0) then BlackList:AddMessage(name .. " " .. "j\195\161 est\195\161 na Lista Negra.", "yellow") else if (realm == nil) then realm = BlackList.realm end if (level == nil) then level = "" end if (class == nil) then class = "" end if (race == nil) then race = "" end if (race == "Scourge") then race = "Undead" end if (reason == nil) then reason = "" end added = time() if ((GetLocale() ~= "zhTW") and (GetLocale() ~= "zhCN") and (GetLocale() ~= "koKR")) then local _, len = string.find(name, "[%z\1-\127\194-\244][\128-\191]*") name = string.upper(string.sub(name, 1, len)) .. string.lower(string.sub(name, len + 1)) end player = {["name"] = name, ["realm"] = realm, ["level"] = level, ["class"] = class, ["race"] = race, ["added"] = added, ["reason"] = reason} table.insert(ESPARTANOS_BlackListedPlayers, player) BlackList:sort() BlackList:HandleEvent("PARTY_MEMBERS_CHANGED") BlackList:AddMessage(name .. " " .. "adicionado \195\160 Lista Negra.", "yellow") end PanelTemplates_Tab_OnClick(FriendsTabHeaderTab4, FriendsTabHeader) if(not BlackListOptionsFrame:IsVisible()) then FriendsFrame:Show() end BlackList:SetSelectedBlackList(BlackList:GetIndexByName(name)) FriendsFrame_Update() BlackList:ShowDetails() end function BlackList:RemovePlayer() local index = BlackList:GetSelectedBlackList() if (index == 0) then BlackList:AddMessage("Jogador n\195\163o encontrado.", "yellow") return end local name = ESPARTANOS_BlackListedPlayers[index]["name"] table.remove(ESPARTANOS_BlackListedPlayers, index) BlackList:AddMessage(name .. " removido da Lista Negra.", "yellow") BlackList:UpdateUI() end function BlackList:UpdateDetails(index, realm, reason, level, class, race) if(not realm) then local realm = GetRealmName() end local player = BlackList:GetPlayerByIndex(index) if ((GetLocale() ~= "zhTW") and (GetLocale() ~= "zhCN") and (GetLocale() ~= "koKR")) then local _, len = string.find(player["name"], "[%z\1-\127\194-\244][\128-\191]*") player["name"] = string.upper(string.sub(player["name"], 1, len)) .. string.lower(string.sub(player["name"], len + 1)) end if (realm ~= nil) then player["realm"] = realm else player["realm"] = ESPARTANOS_BlackListedPlayers[index]["realm"] end if (level ~= nil) then player["level"] = level else player["level"] = ESPARTANOS_BlackListedPlayers[index]["level"] end if (class ~= nil) then player["class"] = class else player["class"] = ESPARTANOS_BlackListedPlayers[index]["class"] end if (race ~= nil) then player["race"] = race else player["race"] = ESPARTANOS_BlackListedPlayers[index]["race"] end if (reason ~= nil) then player["reason"] = reason else player["reason"] = ESPARTANOS_BlackListedPlayers[index]["reason"] end tremove(ESPARTANOS_BlackListedPlayers, index) tinsert(ESPARTANOS_BlackListedPlayers, index, player) end function BlackList:GuildShare() local player = BlackList:GetPlayerByIndex(BlackList:GetSelectedBlackList()) SendAddonMessage("BlackList", format("%s#_#%s#_#%s#_#%s#_#%s#_#%s", player["name"], player["level"], player["class"], player["race"], player["reason"], player["realm"]), "GUILD") BlackList:AddMessage(format("Blacklist Data of \"%s\" send to Guild.", player["name"]), "yellow") return end function BlackList:GetNumBlackLists() if(ESPARTANOS_BlackListedPlayers == nil) then return 0 end return table.getn(ESPARTANOS_BlackListedPlayers) end function BlackList:GetIndexByName(name, realm) if (name == nil) then return 0 end if(ESPARTANOS_BlackListedPlayers == nil) then return 0 end if (realm ~= nil and realm ~= "") then for i = 1, BlackList:GetNumBlackLists() do if (strlower(ESPARTANOS_BlackListedPlayers[i]["name"]) == strlower(name) and strlower(ESPARTANOS_BlackListedPlayers[i]["realm"]) == strlower(realm)) then return i end end else for i = 1, BlackList:GetNumBlackLists() do if (strlower(ESPARTANOS_BlackListedPlayers[i]["name"]) == strlower(name) and strlower(ESPARTANOS_BlackListedPlayers[i]["realm"]) == strlower(BlackList.realm)) then return i end end end return 0 end function BlackList:GetPlayerByIndex(index) if (index ~= nil and index < 1 or index > BlackList:GetNumBlackLists()) then return nil end return ESPARTANOS_BlackListedPlayers[index] end function BlackList:AddMessage(msg, color) if (not ESPARTANOS_BlackListConfig.Chat) then return end local r, g, b = 0, 0, 0 if (color == "red") then r = 1 elseif (color == "yellow") then r, g = 1, 1 end DEFAULT_CHAT_FRAME:AddMessage(msg, r, g, b) end function BlackList:AddErrorMessage(msg, color, timeout) if (not ESPARTANOS_BlackListConfig.Center) then return end local r, g, b = 0, 0, 0 if (color == "red") then r = 1 elseif (color == "yellow") then r, g = 1, 1 end UIErrorsFrame:AddMessage(msg, r, g, b, nil, timeout) end function BlackList:AddSound() if (not ESPARTANOS_BlackListConfig.Sound) then return end PlaySound("PVPTHROUGHQUEUE") end function BlackList:TooltipInfo(tooltip, unitid) if (ESPARTANOS_BlackListConfig.Tooltip == true and unitid and UnitIsPlayer(unitid)) then local name, realm = UnitName(unitid) local player = BlackList:GetPlayerByIndex(BlackList:GetIndexByName(name, realm)) local ttline if(player ~= nil) then local reason = player["reason"] ttline = "Est\195\161 em sua lista negra." GameTooltip:AddLine(ttline, 1, 0, 0, 0) GameTooltip:Show() return end end end function BlackList:GetFaction(race) local faction = 0 if (race == "Human" or race == "Dwarf" or race == "NightElf" or race == "Gnome" or race == "Draenei" or race == "Worgen") then faction = 1 elseif (race == "Orc" or race == "Undead" or race == "Tauren" or race == "Troll" or race == "BloodElf" or race == "Goblin") then faction = 2 end return faction end function BlackList:Convert() local converted = {} for rindex,rvalue in pairs(ESPARTANOS_BlackListedPlayers) do if(type(rindex) == "string" and rvalue ~= nil) then for pindex,pvalue in pairs(ESPARTANOS_BlackListedPlayers[rindex]) do ESPARTANOS_BlackListedPlayers[rindex][pindex]["realm"] = rindex ESPARTANOS_BlackListedPlayers[rindex][pindex]["warn"] = nil table.insert(converted, ESPARTANOS_BlackListedPlayers[rindex][pindex]) end end end ESPARTANOS_BlackListedPlayers = {} ESPARTANOS_BlackListedPlayers = converted BlackList:sort() end function BlackList:sort() table.sort(ESPARTANOS_BlackListedPlayers, BlackList.comparator) end function BlackList.comparator(a, b) local strA = a["name"] local strB = b["name"] local lenA = strlen(strA) local lenB = strlen(strB) local length = 0 if (lenA > lenB) then length = lenA else length = lenB end local byteA = 0 local byteB = 0 local returnValue = true for i=1,length do byteA = strbyte(strA, i) byteB = strbyte(strB, i) if (byteA == nil) then byteA = 0 end if (byteB == nil) then byteB = 0 end if (byteA < byteB) then returnValue = true break elseif (byteA > byteB) then returnValue = false break end end return returnValue end Code:
BlackListOptions = { } local _G = getfenv(0) function BlackListOptions:Handler() if(BlackListOptionsFrame:IsVisible()) then HideUIPanel(BlackListOptionsFrame) else ShowUIPanel(BlackListOptionsFrame) end end function BlackListOptions:SoundCheckButton_OnShow() this:SetChecked(ESPARTANOS_BlackListConfig.Sound) end function BlackListOptions:CenterCheckButton_OnShow() this:SetChecked(ESPARTANOS_BlackListConfig.Center) end function BlackListOptions:ChatCheckButton_OnShow() this:SetChecked(ESPARTANOS_BlackListConfig.Chat) end function BlackListOptions:IgnoreCheckButton_OnShow() this:SetChecked(ESPARTANOS_BlackListConfig.Ignore) end function BlackListOptions:BanCheckButton_OnShow() this:SetChecked(ESPARTANOS_BlackListConfig.Ban) end function BlackListOptions:KickCheckButton_OnShow() this:SetChecked(ESPARTANOS_BlackListConfig.Kick) end function BlackListOptions:BL_RankBox_OnShow() this:SetText(ESPARTANOS_BlackListConfig.Rank) end function BlackListOptions:SoundCheckButton_OnClick() if(1 == this:GetChecked()) then ESPARTANOS_BlackListConfig.Sound = true else ESPARTANOS_BlackListConfig.Sound = false end end function BlackListOptions:CenterCheckButton_OnClick() if(1 == this:GetChecked()) then ESPARTANOS_BlackListConfig.Center = true else ESPARTANOS_BlackListConfig.Center = false end end function BlackListOptions:ChatCheckButton_OnClick() if(1 == this:GetChecked()) then ESPARTANOS_BlackListConfig.Chat = true else ESPARTANOS_BlackListConfig.Chat = false end end function BlackListOptions:IgnoreCheckButton_OnClick() if(1 == this:GetChecked()) then ESPARTANOS_BlackListConfig.Ignore = true else ESPARTANOS_BlackListConfig.Ignore = false end end function BlackListOptions:BanCheckButton_OnClick() if(1 == this:GetChecked()) then ESPARTANOS_BlackListConfig.Ban = true else ESPARTANOS_BlackListConfig.Ban = false end end function BlackListOptions:KickCheckButton_OnClick() if(1 == this:GetChecked()) then ESPARTANOS_BlackListConfig.Kick = true else ESPARTANOS_BlackListConfig.Kick = false end end function BlackListOptions:BL_RankBox_OnTextChanged() local Rank = tonumber(BL_RankBox:GetText()) if not Rank then Rank = 5 end ESPARTANOS_BlackListConfig.Rank = Rank end Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/"> <Script file="BlackListOptions.lua"/> <Frame name="BlackListOptionsFrame" toplevel="true" frameStrata="MEDIUM" movable="true" enableMouse="true" hidden="true" parent="UIParent"> <Size><AbsDimension x="350" y="220" /></Size> <Anchors><Anchor point="CENTER" /></Anchors> <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true"> <BackgroundInsets> <AbsInset left="11" right="12" top="12" bottom="11" /> <Size><AbsDimension x="128" y="17" /></Size> </BackgroundInsets> <TileSize><AbsValue val="32" /></TileSize> <EdgeSize><AbsValue val="32" /></EdgeSize> </Backdrop> <Layers> <Layer level="ARTWORK"> <Texture name="$parentTitle" file="Interface\DialogFrame\UI-DialogBox-Header"> <Size><AbsDimension x="306" y="64" /></Size> <Anchors><Anchor point="TOP"><Offset><AbsDimension x="0" y="12" /></Offset></Anchor></Anchors> </Texture> <FontString inherits="GameFontNormal" text="Ajustes"> <Anchors><Anchor point="TOP" relativeTo="$parent"><Offset><AbsDimension x="0" y="-3" /></Offset></Anchor></Anchors> </FontString> </Layer> </Layers> <Frames> <CheckButton name="SoundCheckButton" inherits="OptionsCheckButtonTemplate"> <Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="20" y="-30" /></Offset></Anchor></Anchors> <Scripts> <OnShow> self:SetChecked(ESPARTANOS_BlackListConfig.Sound) _G[self:GetName().."Text"]:SetText("Tocar som quando passar o mouse") </OnShow> <OnClick> if(self:GetChecked()) then ESPARTANOS_BlackListConfig.Sound = true else ESPARTANOS_BlackListConfig.Sound = false end </OnClick> </Scripts> </CheckButton> <CheckButton name="CenterCheckButton" inherits="OptionsCheckButtonTemplate"> <Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="20" y="-60" /></Offset></Anchor></Anchors> <Scripts> <OnShow> self:SetChecked(ESPARTANOS_BlackListConfig.Center) _G[self:GetName().."Text"]:SetText("Mostrar aviso no centro da tela") </OnShow> <OnClick> if(self:GetChecked()) then ESPARTANOS_BlackListConfig.Center = true else ESPARTANOS_BlackListConfig.Center = false end </OnClick> </Scripts> </CheckButton> <CheckButton name="ChatCheckButton" inherits="OptionsCheckButtonTemplate"> <Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="20" y="-90" /></Offset></Anchor></Anchors> <Scripts> <OnShow> self:SetChecked(ESPARTANOS_BlackListConfig.Chat) _G[self:GetName().."Text"]:SetText("Mostrar mensagens no chat") </OnShow> <OnClick> if(self:GetChecked()) then ESPARTANOS_BlackListConfig.Chat = true else ESPARTANOS_BlackListConfig.Chat = false end </OnClick> </Scripts> </CheckButton> <CheckButton name="TooltipCheckButton" inherits="OptionsCheckButtonTemplate"> <Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="20" y="-120" /></Offset></Anchor></Anchors> <Scripts> <OnShow> self:SetChecked(ESPARTANOS_BlackListConfig.Tooltip) _G[self:GetName().."Text"]:SetText("Mostrar detalhes em Tooltip") </OnShow> <OnClick> if(self:GetChecked()) then ESPARTANOS_BlackListConfig.Tooltip = true else ESPARTANOS_BlackListConfig.Tooltip = false end </OnClick> </Scripts> </CheckButton> <CheckButton name="MItemCheckButton" inherits="OptionsCheckButtonTemplate"> <Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="20" y="-150" /></Offset></Anchor></Anchors> <Scripts> <OnShow> self:SetChecked(ESPARTANOS_BlackListConfig.MItem) _G[self:GetName().."Text"]:SetText('"Lista Negra" nos menus gerais (/reload)') </OnShow> <OnClick> if(self:GetChecked()) then ESPARTANOS_BlackListConfig.MItem = true else ESPARTANOS_BlackListConfig.MItem = false end </OnClick> </Scripts> </CheckButton> <Button name="$parentClose" inherits="OptionsButtonTemplate" text="CLOSE"> <Anchors><Anchor point="CENTER" relativeTo="$parent" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="30" /></Offset></Anchor></Anchors> <Scripts> <OnClick>BlackListOptionsFrame:Hide()</OnClick> </Scripts> </Button> </Frames> </Frame> </Ui> Code:
local SelectedIndex = 1 local Races = {"", "Human", "Dwarf", "NightElf", "Gnome", "Draenei", "Worgen", "Orc", "Undead", "Tauren", "Troll", "BloodElf", "Goblin"} local Classes = {"", "DRUID", "HUNTER", "MAGE", "PALADIN", "PRIEST", "ROGUE", "SHAMAN", "WARLOCK", "WARRIOR", "DEATHKNIGHT"} --[[local Classes = { "", LOCALIZED_CLASS_NAMES_MALE["DRUID"], LOCALIZED_CLASS_NAMES_MALE["HUNTER"], LOCALIZED_CLASS_NAMES_MALE["MAGE"], LOCALIZED_CLASS_NAMES_MALE["PALADIN"], LOCALIZED_CLASS_NAMES_MALE["PRIEST"], LOCALIZED_CLASS_NAMES_MALE["ROGUE"], LOCALIZED_CLASS_NAMES_MALE["SHAMAN"], LOCALIZED_CLASS_NAMES_MALE["WARLOCK"], LOCALIZED_CLASS_NAMES_MALE["WARRIOR"], LOCALIZED_CLASS_NAMES_MALE["DEATHKNIGHT"] }]] function BlackList:InsertUI() tinsert(FRIENDSFRAME_SUBFRAMES, "BlackListFrame") PanelTemplates_SetNumTabs(FriendsTabHeader, 4) PanelTemplates_UpdateTabs(FriendsTabHeader) StaticPopupDialogs["BL_PLAYER"] = { text = "Digite o nome do jogador para adicionar na Lista Negra:", button1 = ACCEPT, button2 = CANCEL, OnShow = function(self) self.editBox:SetText("") end, OnAccept = function(self) BlackList:AddPlayer(self.editBox:GetText()) end, EditBoxOnEnterPressed = function(self) BlackList:AddPlayer(self:GetParent().editBox:GetText()) self:GetParent():Hide() end, EditBoxOnEscapePressed = function(self) self:GetParent():Hide() end, hasEditBox = true, maxLetters = 50, timeout = 0, exclusive = true, whileDead = true, hideOnEscape = true } end function BlackList:ClickBlackList(sel) index = sel:GetID() BlackList:SetSelectedBlackList(index) BlackList:UpdateUI() BlackList:ShowDetails() end function BlackList:SetSelectedBlackList(index) SelectedIndex = index end function BlackList:GetSelectedBlackList() return SelectedIndex end function BlackList:ShowDetails() local player = BlackList:GetPlayerByIndex(BlackList:GetSelectedBlackList()) _G["BlackListDetailsName"]:SetText("Detalhes de " .. player["name"]) if (IsInGuild() == nil) then BlackListEditDetailsFrameShareButton:Disable() else BlackListEditDetailsFrameShareButton:Enable() end BlackListDetailsBlackListedText:SetText(date("%d/%m/%y as %H:%M", player["added"])) BlackListDetailsFrameReasonTextBox:SetText(player["reason"]) BlackListEditDetailsFrameLevel:SetText(player["level"]) BlackListEditDetailsFrameRealm:SetText(player["realm"]) BlackListDetailsFrame.hideOnEscape = true BlackListDetailsFrame:Show() UIDropDownMenu_SetSelectedValue(BlackListEditDetailsFrameRaceDropDown, player["race"]) UIDropDownMenu_SetSelectedValue(BlackListEditDetailsFrameClassDropDown, player["class"]) end function BlackListEditDetailsFrameClassDropDown_Initialize(self) local info = UIDropDownMenu_CreateInfo() UIDropDownMenu_SetWidth(BlackListEditDetailsFrameClassDropDown, 90) UIDropDownMenu_SetButtonWidth(BlackListEditDetailsFrameClassDropDown, 20) for i = 1, getn(Classes), 1 do info.text = Classes[i] info.value = Classes[i] info.func = BlackListEditDetailsFrameClassDropDown_OnClick info.owner = self:GetParent() info.checked = checked UIDropDownMenu_AddButton(info) end end function BlackListEditDetailsFrameClassDropDown_OnClick(self) UIDropDownMenu_SetSelectedValue(BlackListEditDetailsFrameClassDropDown, self.value) end function BlackListEditDetailsFrameRaceDropDown_Initialize(self) local info = UIDropDownMenu_CreateInfo() UIDropDownMenu_SetWidth(BlackListEditDetailsFrameRaceDropDown, 90) UIDropDownMenu_SetButtonWidth(BlackListEditDetailsFrameRaceDropDown, 20) for i = 1, getn(Races), 1 do info.text = Races[i] info.value = Races[i] info.func = BlackListEditDetailsFrameRaceDropDown_OnClick info.owner = self:GetParent() info.checked = checked UIDropDownMenu_AddButton(info) end end function BlackListEditDetailsFrameRaceDropDown_OnClick(self) UIDropDownMenu_SetSelectedValue(BlackListEditDetailsFrameRaceDropDown, self.value) end function BlackListEditDetailsSaveButton_OnClick() local index = BlackList:GetSelectedBlackList() local level = BlackListEditDetailsFrameLevel:GetText() local realm = BlackListEditDetailsFrameRealm:GetText() local class = UIDropDownMenu_GetSelectedValue(BlackListEditDetailsFrameClassDropDown) local race = UIDropDownMenu_GetSelectedValue(BlackListEditDetailsFrameRaceDropDown) BlackList:UpdateDetails(index, realm, nil, level, class, race) BlackListDetailsFrame:Hide() BlackList:UpdateUI() end function BlackList:UpdateUI(setIndex) local numBlackLists = BlackList:GetNumBlackLists() local nameText, name, player, faction local blacklistButton local selectedBlackList = BlackList:GetSelectedBlackList() FauxScrollFrame_Update(FriendsFrameBlackListScrollFrame, numBlackLists, 19, 16) if (numBlackLists > 0) then if (selectedBlackList == 0 or selectedBlackList > numBlackLists) then BlackList:SetSelectedBlackList(1) selectedBlackList = 1 end FriendsFrameRemovePlayerButton:Enable() else FriendsFrameRemovePlayerButton:Disable() end local blacklistOffset = FauxScrollFrame_GetOffset(FriendsFrameBlackListScrollFrame) local blacklistIndex for i=1, 19, 1 do blacklistIndex = i + blacklistOffset player = BlackList:GetPlayerByIndex(blacklistIndex) if(player ~= nil) then faction = BlackList:GetFaction(player["race"]) nameText = _G["FriendsFrameBlackListButton" .. i .. "TextName"] nameText:SetText(player["name"]) realmText = _G["FriendsFrameBlackListButton" .. i .. "RealmName"] realmText:SetText("("..player["realm"]..")") end blacklistButton = _G["FriendsFrameBlackListButton" .. i] blacklistButton:SetID(blacklistIndex) if (faction ~= nil and faction > 0) then factionIcon = _G["FriendsFrameBlackListButton" .. i .. "FactionFrameInsignia"] if (faction == 1) then factionIcon:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Factions.blp") factionIcon:SetTexCoord(0, 0.5, 0, 1) else factionIcon:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Factions.blp") factionIcon:SetTexCoord(0.5, 1, 0, 1) end end if (blacklistIndex == selectedBlackList) then blacklistButton:LockHighlight() else blacklistButton:UnlockHighlight() end if (blacklistIndex > numBlackLists) then blacklistButton:Hide() else blacklistButton:Show() end end end Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/FrameXML"> <Script file="BlackList.lua" /> <Script file="BlackListFunctions.lua" /> <Script file="BlackListUI.lua" /> <Button name="FriendsTabHeaderTab4" parent="FriendsTabHeader" inherits="TabButtonTemplate" id="4"> <Size> <AbsDimension x="50" y="32"/> </Size> <Anchors> <Anchor point="LEFT" relativeTo="FriendsTabHeaderTab3" relativePoint="RIGHT"> <Offset> <AbsDimension x="0" y="0"/> </Offset> </Anchor> </Anchors> <Scripts> <OnLoad> self:SetText("*") PanelTemplates_TabResize(self,0) </OnLoad> <OnClick> PanelTemplates_Tab_OnClick(self, FriendsTabHeader) FriendsFrame_Update() PlaySound("igMainMenuOptionCheckBoxOn") </OnClick> </Scripts> </Button> <Button name="FriendsFrameBlackListButtonTemplate" virtual="true"> <Size> <AbsDimension x="298" y="16" /> </Size> <Frames> <Frame name="$parentFactionFrame"> <Size><AbsDimension x="16" y="16" /></Size> <Anchors><Anchor point="RIGHT"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> <Layers> <Layer level="ARTWORK"> <Texture name="$parentInsignia"> <Size><AbsDimension x="16" y="16" /></Size> <Anchors><Anchor point="RIGHT"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Texture> </Layer> </Layers> </Frame> <Frame name="$parentText" setAllPoints="true"> <Layers> <Layer level="BORDER"> <FontString name="$parentName" inherits="GameFontNormal" justifyH="LEFT"> <Size> <AbsDimension x="180" y="16"/> </Size> <Anchors> <Anchor point="LEFT"> <Offset> <AbsDimension x="6" y="1" /> </Offset> </Anchor> </Anchors> </FontString> </Layer> </Layers> </Frame> <Frame name="$parentRealm" setAllPoints="true"> <Layers> <Layer level="BORDER"> <FontString name="$parentName" inherits="GameFontNormal" justifyH="RIGHT"> <Size> <AbsDimension x="120" y="16"/> </Size> <Anchors> <Anchor point="RIGHT"> <Offset> <AbsDimension x="-20" y="1" /> </Offset> </Anchor> </Anchors> </FontString> </Layer> </Layers> </Frame> </Frames> <Scripts> <OnClick> BlackList:ClickBlackList(self) PlaySound("igMainMenuOptionCheckBoxOn") </OnClick> </Scripts> <HighlightTexture file="Interface\QuestFrame\UI-QuestTitleHighlight" alphaMode="ADD" /> </Button> <CheckButton name="BlackListDetailsCheckButtonTemplate" inherits="OptionsCheckButtonTemplate" virtual="true"> <Scripts> <OnClick>BlackList:UpdateDetails(BlackList:GetSelectedBlackList(), BlackListDetailsFrameCheckButton1)</OnClick> </Scripts> </CheckButton> <Frame name="BlackListFrame" parent="FriendsFrame" hidden="true" setAllPoints="true"> <Frames> <Button name="FriendsFrameBlacklistPlayerButton" inherits="OptionsButtonTemplate"> <Size><AbsDimension x="100" y="20" /></Size> <Anchors><Anchor point="BOTTOMLEFT" relativeTo="FriendsFrame"><Offset><AbsDimension x="4" y="5" /></Offset></Anchor></Anchors> <Scripts> <OnLoad> self:SetText("Adicionar") self:SetFrameLevel( self:GetFrameLevel() + 3 ) </OnLoad> <OnClick> BlackListDetailsFrame:Hide() BlackListOptionsFrame:Hide() BlackList:AddPlayer("target") </OnClick> </Scripts> </Button> <Button name="FriendsFrameRemovePlayerButton" inherits="OptionsButtonTemplate"> <Size><AbsDimension x="100" y="20" /></Size> <Anchors><Anchor point="BOTTOMLEFT" relativeTo="FriendsFrame"><Offset><AbsDimension x="111" y="5" /></Offset></Anchor></Anchors> <Scripts> <OnLoad> self:SetText("Remover") self:SetFrameLevel( self:GetFrameLevel() + 3 ) </OnLoad> <OnClick> BlackList:RemovePlayer() BlackListDetailsFrame:Hide() </OnClick> </Scripts> </Button> <Button name="FriendsFrameOptionsButton" inherits="OptionsButtonTemplate"> <Size><AbsDimension x="75" y="20" /></Size> <Anchors><Anchor point="BOTTOMLEFT" relativeTo="FriendsFrame"><Offset><AbsDimension x="257" y="5" /></Offset></Anchor></Anchors> <Scripts> <OnLoad> self:SetText("Ajustes") self:SetFrameLevel( self:GetFrameLevel() + 3 ) </OnLoad> <OnClick> if(BlackListOptionsFrame:IsVisible()) then BlackListOptionsFrame:Hide() else BlackListOptionsFrame:Show() end </OnClick> </Scripts> </Button> <Button name="FriendsFrameBlackListButton1" inherits="FriendsFrameBlackListButtonTemplate" id="1"> <Anchors><Anchor point="TOPLEFT" relativeTo="FriendsFrame"><Offset><AbsDimension x="10" y="-89" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton2" inherits="FriendsFrameBlackListButtonTemplate" id="2"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton1" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton3" inherits="FriendsFrameBlackListButtonTemplate" id="3"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton2" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton4" inherits="FriendsFrameBlackListButtonTemplate" id="4"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton3" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton5" inherits="FriendsFrameBlackListButtonTemplate" id="5"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton4" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton6" inherits="FriendsFrameBlackListButtonTemplate" id="6"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton5" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton7" inherits="FriendsFrameBlackListButtonTemplate" id="7"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton6" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton8" inherits="FriendsFrameBlackListButtonTemplate" id="8"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton7" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton9" inherits="FriendsFrameBlackListButtonTemplate" id="9"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton8" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton10" inherits="FriendsFrameBlackListButtonTemplate" id="10"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton9" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton11" inherits="FriendsFrameBlackListButtonTemplate" id="11"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton10" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton12" inherits="FriendsFrameBlackListButtonTemplate" id="12"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton11" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton13" inherits="FriendsFrameBlackListButtonTemplate" id="13"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton12" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton14" inherits="FriendsFrameBlackListButtonTemplate" id="14"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton13" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton15" inherits="FriendsFrameBlackListButtonTemplate" id="15"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton14" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton16" inherits="FriendsFrameBlackListButtonTemplate" id="16"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton15" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton17" inherits="FriendsFrameBlackListButtonTemplate" id="17"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton16" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton18" inherits="FriendsFrameBlackListButtonTemplate" id="18"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton17" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <Button name="FriendsFrameBlackListButton19" inherits="FriendsFrameBlackListButtonTemplate" id="19"> <Anchors><Anchor point="TOP" relativeTo="FriendsFrameBlackListButton18" relativePoint="BOTTOM"><Offset><AbsDimension x="0" y="0" /></Offset></Anchor></Anchors> </Button> <ScrollFrame name="FriendsFrameBlackListScrollFrame" inherits="FauxScrollFrameTemplate"> <Anchors> <Anchor point="TOPLEFT" relativePoint="TOPLEFT"> <Offset> <AbsDimension x="9" y="-89"/> </Offset> </Anchor> <Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT"> <Offset> <AbsDimension x="-32" y="30"/> </Offset> </Anchor> </Anchors> <Scripts> <OnVerticalScroll> FauxScrollFrame_OnVerticalScroll(self, offset, 16, function() BlackList:UpdateUI() end) </OnVerticalScroll> </Scripts> </ScrollFrame> </Frames> <Scripts> <OnShow> BlackList:UpdateUI() </OnShow> <OnHide> BlackListDetailsFrame:Hide() BlackListOptionsFrame:Hide() StaticPopup_Hide("BL_PLAYER") </OnHide> </Scripts> </Frame> <Frame name="BlackListDetailsFrame" toplevel="true" parent="UIParent" movable="true" enableMouse="true" hidden="true"> <Size><AbsDimension x="297" y="320" /></Size> <Anchors><Anchor point="TOPLEFT" relativeTo="FriendsFrameBlackListScrollFrame" relativePoint="TOPRIGHT"><Offset><AbsDimension x="30" y="10" /></Offset></Anchor></Anchors> <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true"> <BackgroundInsets><AbsInset left="11" right="12" top="12" bottom="11" /></BackgroundInsets> <TileSize><AbsValue val="32" /></TileSize> <EdgeSize><AbsValue val="32" /></EdgeSize> </Backdrop> <Layers> <Layer level="OVERLAY"> <Texture name="BlackListDetailsCorner" file="Interface\DialogFrame\UI-DialogBox-Corner"> <Size><AbsDimension x="32" y="32" /></Size> <Anchors><Anchor point="TOPRIGHT"><Offset><AbsDimension x="-6" y="-7" /></Offset></Anchor></Anchors> </Texture> </Layer> <Layer level="ARTWORK"> <FontString name="BlackListDetailsName" inherits="GameFontNormal" text=""> <Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="17" y="-18" /></Offset></Anchor></Anchors> </FontString> <FontString name="BlackListDetailsBlackListedLabel" inherits="GameFontNormal" text="Listado em:"> <Anchors><Anchor point="TOPLEFT" relativeTo="BlackListDetailsName" relativePoint="BOTTOMLEFT"><Offset><AbsDimension x="0" y="-10" /></Offset></Anchor></Anchors> </FontString> <FontString name="BlackListDetailsBlackListedText" inherits="GameFontHighlight" justifyH="LEFT"> <Anchors><Anchor point="LEFT" relativeTo="BlackListDetailsBlackListedLabel" relativePoint="RIGHT"><Offset><AbsDimension x="2" y="0" /></Offset></Anchor></Anchors> </FontString> <FontString name="BlackListDetailsReasonLabel" inherits="GameFontNormal" text="Motivo para ser listado:"> <Anchors><Anchor point="TOPLEFT" relativeTo="BlackListDetailsBlackListedLabel" relativePoint="BOTTOMLEFT"><Offset><AbsDimension x="2" y="-11" /></Offset></Anchor></Anchors> </FontString> <FontString name="BlackListDetailsLevelLabel" inherits="GameFontNormal" text="Level"> <Anchors><Anchor point="LEFT" relativeTo="BlackListDetailsBlackListedLabel" relativePoint="BOTTOMLEFT"><Offset><AbsDimension x="10" y="-135" /></Offset></Anchor></Anchors> </FontString> <FontString name="BlackListDetailsRealmLabel" inherits="GameFontNormal" text="Servidor"> <Anchors><Anchor point="LEFT" relativeTo="BlackListDetailsLevelLabel" relativePoint="LEFT"><Offset><AbsDimension x="130" y="0" /></Offset></Anchor></Anchors> </FontString> <FontString name="BlackListDetailsRaceLabel" inherits="GameFontNormal" text="Tipo"> <Anchors><Anchor point="LEFT" relativeTo="BlackListDetailsLevelLabel" relativePoint="LEFT"><Offset><AbsDimension x="2" y="-50" /></Offset></Anchor></Anchors> </FontString> <FontString name="BlackListDetailsClassLabel" inherits="GameFontNormal" text="Classe"> <Anchors><Anchor point="LEFT" relativeTo="BlackListDetailsRealmLabel" relativePoint="LEFT"><Offset><AbsDimension x="0" y="-50" /></Offset></Anchor></Anchors> </FontString> </Layer> </Layers> <Frames> <Button name="BlackListDetailsCloseButton" inherits="UIPanelCloseButton"> <Anchors><Anchor point="TOPRIGHT"><Offset><AbsDimension x="-2" y="-3" /></Offset></Anchor></Anchors> </Button> <Frame name="BlackListDetailsFrameReasonTextBackground"> <Size><AbsDimension x="266" y="93" /></Size> <Anchors><Anchor point="TOPLEFT" relativeTo="BlackListDetailsReasonLabel" relativePoint="BOTTOMLEFT"><Offset><AbsDimension x="-1" y="-4" /></Offset></Anchor></Anchors> <Backdrop bgFile="Interface\Tooltips\UI-Tooltip-Background" edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true"> <EdgeSize><AbsValue val="16" /></EdgeSize> <TileSize><AbsValue val="16" /></TileSize> <BackgroundInsets><AbsInset left="5" right="5" top="5" bottom="5" /></BackgroundInsets> </Backdrop> <Frames> <ScrollFrame name="BlackListDetailsFrameScrollFrame" inherits="UIPanelScrollFrameTemplate"> <Size><AbsDimension x="233" y="81" /></Size> <Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="5" y="-7" /></Offset></Anchor></Anchors> <Scripts> <OnMouseDown>BlackListDetailsFrameReasonTextBox:SetFocus()</OnMouseDown> <OnMouseUp>BlackListDetailsFrameReasonTextBox:SetFocus()</OnMouseUp> </Scripts> <ScrollChild> <EditBox name="BlackListDetailsFrameReasonTextBox" letters="500" multiLine="true" autoFocus="false"> <Size><AbsDimension x="230" y="81" /></Size> <Scripts> <OnEscapePressed>self:ClearFocus()</OnEscapePressed> <OnTextChanged> local scrollBar = _G[self:GetParent():GetName().."ScrollBar"] self:GetParent():UpdateScrollChildRect() local min local max min, max = scrollBar:GetMinMaxValues() if ( max > 0 and (self.max ~= max) ) then self.max = max scrollBar:SetValue(max) end BlackList:UpdateDetails(BlackList:GetSelectedBlackList(), nil, self:GetText()) </OnTextChanged> </Scripts> <FontString inherits="GameFontHighlight" /> </EditBox> </ScrollChild> </ScrollFrame> </Frames> <Scripts> <OnLoad> self:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) self:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) </OnLoad> </Scripts> </Frame> <Frame name="BlackListEditDetailsFrameLevelBackground"> <Size><AbsDimension x="38" y="30" /></Size> <Anchors><Anchor point="TOPLEFT" relativeTo="BlackListDetailsLevelLabel" relativePoint="BOTTOMLEFT"><Offset><AbsDimension x="-1" y="-4" /></Offset></Anchor></Anchors> <Backdrop bgFile="Interface\Tooltips\UI-Tooltip-Background" edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true"> <EdgeSize><AbsValue val="16" /></EdgeSize> <TileSize><AbsValue val="16" /></TileSize> <BackgroundInsets><AbsInset left="5" right="5" top="5" bottom="5" /></BackgroundInsets> </Backdrop> <Frames> <EditBox name="BlackListEditDetailsFrameLevel" autoFocus="false" frameStrata="HIGH" historyLines="32"> <Size><AbsDimension x="64" y="32" /></Size> <Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="9" y="1" /></Offset></Anchor></Anchors> <Scripts> <OnEscapePressed>self:ClearFocus()</OnEscapePressed> </Scripts> <FontString inherits="ChatFontNormal" bytes="3" /> </EditBox> </Frames> <Scripts> <OnLoad> self:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) self:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) </OnLoad> </Scripts> </Frame> <Frame name="BlackListEditDetailsFrameRealmBackground"> <Size> <AbsDimension x="110" y="30" /> </Size> <Anchors> <Anchor point="TOPLEFT" relativeTo="BlackListDetailsRealmLabel" relativePoint="BOTTOMLEFT"> <Offset> <AbsDimension x="-1" y="-4" /> </Offset> </Anchor> </Anchors> <Backdrop bgFile="Interface\Tooltips\UI-Tooltip-Background" edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true"> <EdgeSize> <AbsValue val="16" /> </EdgeSize> <TileSize> <AbsValue val="16" /> </TileSize> <BackgroundInsets> <AbsInset left="5" right="5" top="5" bottom="5" /> </BackgroundInsets> </Backdrop> <Frames> <EditBox name="BlackListEditDetailsFrameRealm" autoFocus="false" frameStrata="HIGH" historyLines="32"> <Size> <AbsDimension x="100" y="32" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset> <AbsDimension x="9" y="1" /> </Offset> </Anchor> </Anchors> <Scripts> <OnEscapePressed> self:ClearFocus() </OnEscapePressed> </Scripts> <FontString inherits="ChatFontNormal" bytes="50" /> </EditBox> </Frames> <Scripts> <OnLoad> self:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) self:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) </OnLoad> </Scripts> </Frame> <Frame name="BlackListEditDetailsFrameRaceDropDown" inherits="UIDropDownMenuTemplate"> <Anchors> <Anchor point="TOPLEFT" relativeTo="BlackListDetailsRaceLabel" relativePoint="BOTTOMLEFT"> <Offset> <AbsDimension x="-18" y="0" /> </Offset> </Anchor> </Anchors> <Scripts> <OnLoad> UIDropDownMenu_JustifyText(self, "LEFT") </OnLoad> <OnShow> UIDropDownMenu_Initialize(self, BlackListEditDetailsFrameRaceDropDown_Initialize) </OnShow> </Scripts> </Frame> <Frame name="BlackListEditDetailsFrameClassDropDown" inherits="UIDropDownMenuTemplate"> <Anchors> <Anchor point="TOPLEFT" relativeTo="BlackListDetailsClassLabel" relativePoint="BOTTOMLEFT"> <Offset> <AbsDimension x="-18" y="0" /> </Offset> </Anchor> </Anchors> <Scripts> <OnLoad> UIDropDownMenu_JustifyText(self, "LEFT") </OnLoad> <OnShow> UIDropDownMenu_Initialize(self, BlackListEditDetailsFrameClassDropDown_Initialize) </OnShow> </Scripts> </Frame> <Button name="BlackListEditDetailsFrameShareButton" inherits="UIPanelButtonTemplate" text="Divulgar"> <Size> <AbsDimension x="100" y="21" /> </Size> <Anchors> <Anchor point="TOPLEFT" relativeTo="BlackListEditDetailsFrameRaceDropDown" relativePoint="BOTTOMCENTER"> <Offset> <AbsDimension x="20" y="-40" /> </Offset> </Anchor> </Anchors> <Scripts> <OnClick> BlackList:GuildShare() </OnClick> </Scripts> </Button> <Button name="BlackListEditDetailsFrameSaveButton" inherits="UIPanelButtonTemplate" text="Salvar"> <Size> <AbsDimension x="100" y="21" /> </Size> <Anchors> <Anchor point="TOPLEFT" relativeTo="BlackListEditDetailsFrameClassDropDown" relativePoint="BOTTOMCENTER"> <Offset> <AbsDimension x="20" y="-40" /> </Offset> </Anchor> </Anchors> <Scripts> <OnClick> BlackListEditDetailsSaveButton_OnClick() </OnClick> </Scripts> </Button> </Frames> </Frame> <Frame name="BlackListTopFrame" parent="UIParent" hidden="true"> <Scripts> <OnLoad> BlackList:OnLoad() </OnLoad> <OnEvent> BlackList:HandleEvent(self, event, ...) </OnEvent> </Scripts> </Frame> </Ui> |
|
09-04-12, 01:58 AM | #6 |
1. You should change all instances of VARIABLES_LOADED to PLAYER_LOGIN... VARIABLES_LOADED has not been useful as an addon loading event since the Burning Crusade.
2. Inside the BlackList:RegisterEvents() function, you need to register for the addon's message prefix: Code:
if not IsAddonMessagePrefixRegistered("BlackList") then RegisterAddonMessagePrefix("BlackList") end Also, make sure you have BugSack or some other error catching addon installed. The default UI's error display is not good enough.
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
09-04-12, 02:24 AM | #7 |
09-04-12, 03:17 AM | #8 |
@ballagarba
The default UI's error display only gives you the error. It doesn't provide you with any extra insight into what triggered the error (function calls, the contents of relevant variables, etc.). |
|
09-04-12, 03:34 AM | #9 |
It is also incapable of showing errors that occur during the loading process. Since many of the errors you'll encounter while developing an addon occur during the loading process, this makes the built-in error display completely useless.
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
09-04-12, 04:14 AM | #10 |
Thank you my friend,
I realized the changes that you mentioned and ran the addon with the BugSack and it detected the following error. Code:
1x Espartanos-0.1\Lista\BlackList.lua:31: attempt to call method "RegisterSlashCmds" (a nil value) Espartanos-0.1\Lista\BlackList.lua:31: in function "OnLoad" <string>:"*:OnLoad":1: in function <string>:"*:OnLoad":1 Locals: self = BlackListTopFrame { 0 = <userdata> } |
|
09-04-12, 08:32 PM | #11 |
I found the place where it was giving error and corrects, but the addon does not share the database with other guild that have the addon.
Anyone know what might be happening? no error .lua is being detected by BugSack |
|
WoWInterface » Developer Discussions » General Authoring Discussion » What does this function? |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|