09-21-15, 03:16 AM | #1 |
Getting rid of realm suffixes
I have been trying to find a solution to something that has been bothering me for a while now. The realm names that you see behind a person's name have been bothering me to no end. i.e. Gryns-Aggrammar. They feel like clutter, and it has been my undying mission to get rid of them everywhere.
With the help of a wide variety of addons and scripts I have removed them from chat, raid frames, and now, thanks to TipTac -tooltips. And even though TipTac removes them from player tooltips, it leaves the realm names in a few other tooltips. Amongst which; in the tooltip for pets and companions (Gryns-Aggramar's Pet/Companion/Minion), and as a loot/dead body tooltip in a party/raid (belongs to Gryns-Aggramar). Now I've kludged together a solution for the pet/companion tooltips (through hours of experimentation, because I know nothing about LUA code. But I can't find a solution for the loot/dead body tooltip. Here are the parts of the code that I ruined so it serves my own purpose; " -- Find NPC Title -- 09.08.22: Should now work with colorblind mode if (first) and (not u.isPlayer) then u.title = (isColorBlind and GameTooltipTextLeft3 or GameTooltipTextLeft2):GetText(); if (u.title) and (u.title:find(TT_LevelMatch)) or (u.title:find("-")) then u.title = nil; " This is for the pets, it changes the owner line to a class and level line, not ideal, but at least the damn realm name is gone. " -- BattlePets elseif (isPetWild or isPetCompanion) then lineOne[#lineOne + 1] = reaction; lineOne[#lineOne + 1] = name; lineInfo[#lineInfo + 1] = " "; lineInfo[#lineInfo + 1] = cfg.colRace; local petType = UnitBattlePetType(unit) or 5; lineInfo[#lineInfo + 1] = name; if (isPetWild) then lineInfo[#lineInfo + 1] = " "; lineInfo[#lineInfo + 1] = UnitCreatureFamily(unit) or UnitCreatureType(unit); else if not (petLevelLineIndex) then for i = 2, gtt:NumLines() do local gttLineText = _G["GameTooltipTextLeft"..i]:GetText(); if (type(gttLineText) == "string") and (gttLineText:find("-")) then petLevelLineIndex = i; break; end end end lineInfoIndex = petLevelLineIndex or 2; local expectedLine = 3 + (isColorBlind and 1 or 0); if (lineInfoIndex > expectedLine) then GameTooltipTextLeft2:SetFormattedText("%s%s",reaction,u.title); end end " This is for companions and battle pets, again not ideal, because this changes the owner line to the level and name of the pet, and only works if the pet does not have a custom name. But at least the damn realm name is gone. I was wondering if anyone could help me out with the code, I would like to remove the realm suffix from the pets and companions tooltips and the loot/dead body tooltip. I don't mind just the player's name, I would just like to get the realm-suffix removed. If that's not possible, then lets remove the whole bloody line. Thanks in advance, Gryns. PS. There are also a few places where the suffixes still are but if they are possible to remove as well, then by all means, let's get them too. These are the current target floating name, and in chat whispers. These still contain the realm suffixes for some reason.
__________________
-- Live like a King, laugh like his Jester. -- |
|
09-22-15, 02:10 AM | #2 |
Possibly slightly overengineered, and not actually tested, but this should take care of pets, corpse loot** and any other unit tooltip line patterns you choose to add:
Code:
local ownerStrings = { ["(%s)'s Companion"] = "%s's Companion", ["(%s)'s Guardian"] = "%s's Companion", ["(%s)'s Minion"] = "%s's Companion", ["(%s)'s Pet"] = "%s's Companion", ["(%s)'s Totem"] = "%s's Companion", -- ** for corpse loot, add the patterns here; I don't know what it looks like offhand } local shortVersions = setmetatable({}, { __mode = "kv", __index = function(t, k) for search, replace in pairs(ownerStrings) do local owner = strmatch(text, search) if owner then local v = format(replace, (gsub(owner, "%-.+", ""))) t[k] = v return v end end t[k] = false end }) GameTooltip:HookScript("OnTooltipSetUnit", function(tooltip) local _, unit = tooltip:GetUnit() if UnitIsBattlePet(unit) or (UnitIsDead(unit) and not UnitPlayerControlled(unit)) then for i = 2, tooltip:NumLines() do -- no need to check line 1, it's always the unit's name local line = _G["GameTooltipTextLeft"..i] local text = shortVersions[line:GetText() or ""] if text then line:SetText(text) end end end end) Code:
local orig_AddMessage = {} local AddMessage = function(frame, message, ...) if type(message) == "string" then message = gsub("|Hplayer:(.-)|h%[([^%-]+)%-[^|]+([^%]]*)%]|h", "|Hplayer:%1|h[%2%3]|h") return orig_AddMessage(frame, message, ...) end end for i = 1, NUM_CHAT_WINDOWS do local f = _G["ChatFrame" .. i]) orig_AddMessage[f] = f.AddMessage f.AddMessage = AddMessage end local orig_FCF_OpenTemporaryWindow = FCF_OpenTemporaryWindow FCF_OpenTemporaryWindow = function(...) local f = orig_FCF_OpenTemporaryWindow(...) orig_addMessage[f] = f.AddMessage f.AddMessage = AddMessage return f end
__________________
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-22-15, 04:40 AM | #3 |
Hey Phanx, thanks for the quick reply.
Tried both your scripts, but both failed to work. I put them both in separate addons, and added the corpse loot pattern to your first script. Here's what I used for the tooltips. Code:
local ownerStrings = { ["(%s)'s Companion"] = "%s's Companion", ["(%s)'s Guardian"] = "%s's Guardian", ["(%s)'s Minion"] = "%s's Minion", ["(%s)'s Pet"] = "%s's Pet", ["(%s)'s Totem"] = "%s's Totem", ["Loot: (%s)"] = "Loot: %s", } local shortVersions = setmetatable({}, { __mode = "kv", __index = function(t, k) for search, replace in pairs(ownerStrings) do local owner = strmatch(text, search) if owner then local v = format(replace, (gsub(owner, "%-.+", ""))) t[k] = v return v end end t[k] = false end }) GameTooltip:HookScript("OnTooltipSetUnit", function(tooltip) local _, unit = tooltip:GetUnit() if UnitIsBattlePet(unit) or (UnitIsDead(unit) and not UnitPlayerControlled(unit)) then for i = 2, tooltip:NumLines() do -- no need to check line 1, it's always the unit's name local line = _G["GameTooltipTextLeft"..i] local text = shortVersions[line:GetText() or ""] if text then line:SetText(text) end end end end) Code:
local orig_AddMessage = {} local AddMessage = function(frame, message, ...) if type(message) == "string" then message = gsub("|Hplayer:(.-)|h%[([^%-]+)%-[^|]+([^%]]*)%]|h", "|Hplayer:%1|h[%2%3]|h") return orig_AddMessage(frame, message, ...) end end for i = 1, NUM_CHAT_WINDOWS do local f = _G["ChatFrame" .. i]) orig_AddMessage[f] = f.AddMessage f.AddMessage = AddMessage end local orig_FCF_OpenTemporaryWindow = FCF_OpenTemporaryWindow FCF_OpenTemporaryWindow = function(...) local f = orig_FCF_OpenTemporaryWindow(...) orig_addMessage[f] = f.AddMessage f.AddMessage = AddMessage return f end This is what I used for chat before, which removed the suffixes from the chat channels, but not from the whispers. Code:
local a = getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage = function(s,t,...) return a(s,t:gsub("|Hplayer:(.-)|h%[([^-]+).-%]","|Hplayer:%1|h[%2]"),...) end Thanks again, Gryns
__________________
-- Live like a King, laugh like his Jester. -- |
|
09-22-15, 08:06 PM | #4 |
There's probably an error; I didn't test either in-game. Install Bugger and report back with the errors from each.
__________________
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-22-15, 10:10 PM | #5 | |
Unless you're running an addon that's interfering with it, or you're talking about battle net whispers (which I don't even think can contain a realm?), that should still be removing the realm name from the chat. I know Prat was causing issues with the original pattern I was using because of all the junk they added to the player link (mostly class coloring), but that was fixed in the more recent version of the addon than what you posted here. |
||
09-23-15, 09:26 AM | #6 | ||
I use BasicChatMods, but even with that disabled it doesn't filter the suffix. Don't get me wrong though, it does remove it from the main chat window, just not when you type. To clarify, when I click on a name in trade chat for instance, it will show "Tell Semlar-Aggramar:" when you are typing in your message, but the conversation itself has the realm suffix removed. I would just like the realm suffix removed in the edit box as well as in the chat window. If that's at all possible, of course.
As for the tooltips. Variations of these showed when mousing over a pet/companion/bodyguard/etc: Code:
95x TooltipHideRealm\code.lua:17: bad argument #1 to 'strmatch' (string expected, got nil) [C]:: in function 'strmatch' TooltipHideRealm\code.lua:17: in function <TooltipHideRealm\code.lua:15> TooltipHideRealm\code.lua:34: in function <TooltipHideRealm\code.lua:28> [C]:: ? [C]:: ? [C]:: ? Locals: t = <table> k = "Minalla-Silvermoon's Companion" (for generator) = <function> defined =[C]:-1 (for state) = <table> { (%s)'s Minion = "%s's Minion" (%s)'s Totem = "%s's Totem" (%s)'s Companion = "%s's Companion" Loot: (%s) = "Loot : %s" (%s)'s Pet = "%s's Pet" (%s)'s Guardian = "%s's Guardian" } (for control) = "(%s)'s Minion" search = "(%s)'s Minion" replace = "%s's Minion" ownerStrings = <table> { (%s)'s Minion = "%s's Minion" (%s)'s Totem = "%s's Totem" (%s)'s Companion = "%s's Companion" Loot: (%s) = "Loot : %s" (%s)'s Pet = "%s's Pet" (%s)'s Guardian = "%s's Guardian" } And variations of these when you moused over a corpse that had loot assigned to a party/raid member: Code:
82x TooltipHideRealm\code.lua:17: bad argument #1 to 'strmatch' (string expected, got table) [C]:: in function 'strmatch' TooltipHideRealm\code.lua:17: in function <TooltipHideRealm\code.lua:15> TooltipHideRealm\code.lua:34: in function <TooltipHideRealm\code.lua:28> [C]:: ? [C]:: ? [C]:: ? Locals: t = <table> k = "Shadow Council" (for generator) = <function> defined =[C]:-1 (for state) = <table> { (%s)'s Minion = "%s's Minion" (%s)'s Totem = "%s's Totem" (%s)'s Companion = "%s's Companion" Loot: (%s) = "Loot : %s" (%s)'s Pet = "%s's Pet" (%s)'s Guardian = "%s's Guardian" } (for control) = "(%s)'s Minion" search = "(%s)'s Minion" replace = "%s's Minion" ownerStrings = <table> { (%s)'s Minion = "%s's Minion" (%s)'s Totem = "%s's Totem" (%s)'s Companion = "%s's Companion" Loot: (%s) = "Loot : %s" (%s)'s Pet = "%s's Pet" (%s)'s Guardian = "%s's Guardian" } And for chat: Code:
1x ChatHideRealm\code.lua:14: unexpected symbol near ')' Which if I had to guess, is this part of the script: Code:
for i = 1, NUM_CHAT_WINDOWS do local f = _G["ChatFrame" .. i]) orig_AddMessage[f] = f.AddMessage f.AddMessage = AddMessage end Gryns
__________________
-- Live like a King, laugh like his Jester. -- |
|||
09-23-15, 01:56 PM | #7 | ||
Alright, I threw something together that I think should do what you're after. Lua Code:
Last edited by semlar : 09-23-15 at 03:01 PM. |
|||
09-24-15, 02:26 PM | #8 | |
Also, I added this to the code of your other addon, NoRealm, but that didn't seem to work. It only seemed to work when I enabled it as a separate addon, how can I merge the two? Thanks again, really. Joey
__________________
-- Live like a King, laugh like his Jester. -- |
||
09-24-15, 03:20 PM | #9 | ||
The problem with the system messages is that you'll either need to use a pattern verbose enough to match almost ANYTHING with a hyphen in it (which I'm not sure is really an issue) or make a list of all of the global strings that might contain a player name (which would be a nightmare to compile). The fact that players can use unicode characters in their names complicates things (not to mention other languages). I'm not sure whether it will actually work, but you can try something like this.. Lua Code:
Lua Code:
Last edited by semlar : 09-24-15 at 03:29 PM. |
|||
09-24-15, 11:02 PM | #10 | |
Code:
local owner = strmatch(text, search) Code:
local owner = strmatch(k, search)
__________________
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-25-15, 07:18 AM | #11 | ||
Code:
4x ChatHideRealm\code.lua:13: malformed pattern (missing ']') [C]:: in function 'gsub' ChatHideRealm\code.lua:13: in function 'filterFunc' FrameXML\ChatFrame.lua:2946: in function 'ChatFrame_MessageEventHandler' FrameXML\ChatFrame.lua:2721: in function 'ChatFrame_OnEvent' [string "*:OnEvent"]:1: in function <[string "*:OnEvent"]:1> Locals: self = ChatFrame1 { 0 = <userdata> isUninteractable = false flashTimer = 0 isInitialized = 1 mouseOutTime = 0.032999999821186 tellTimer = 47089.682 resizeButton = ChatFrame1ResizeButton { } buttonFrame = ChatFrame1ButtonFrame { } defaultLanguage = "Common" oldAlpha = 0 channelList = <table> { } alternativeDefaultLanguage = "Common" clickAnywhereButton = ChatFrame1ClickAnywhereButton { } isStaticDocked = true mouseInTime = 0 editBox = ChatFrame1EditBox { } checkedGMOTD = true isLocked = true name = "General" buttonSide = "left" isDocked = 1 zoneChannelList = <table> { } AddMessage = <function> defined @BasicChatMods\BasicCore.lua:70 messageTypeList = <table> { } } event = "CHAT_MSG_SYSTEM" msg = "You have unlearned [Glyph of Contemplation]." (*temporary) = false Thanks for the response Phanx. I changed the line, and it removed the errors completely. It did not remove the realm suffix from the tooltips however.
__________________
-- Live like a King, laugh like his Jester. -- |
|||
09-25-15, 08:24 AM | #12 |
Please post exactly what you have in the file.
|
|
09-25-15, 08:44 AM | #13 | |
Of course, I merged all the scripts that you gave me so far. This is what I have:
Code:
-- This file is loaded from "ChatHideRealm.toc" -- ChatHideRealm local a,g = getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage,gsub getmetatable(DEFAULT_CHAT_FRAME).__index.AddMessage = function(s,t,...) if s == ChatFrame2 then return a(s,t,...) end -- combat log return a(s,g(t,"|Hplayer:(.-)|h(.-)|h",function(a,b) return "|Hplayer:"..a.."|h"..g(b,"-([^%]:]+)(.*)","%2|r").."|h" end),...) end ChatFrame_AddMessageEventFilter('CHAT_MSG_SYSTEM', function(self, event, msg, ...) return false, (msg:gsub('%f[^\0%s]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[\0%s]', '%1')), ... end) hooksecurefunc('ChatEdit_UpdateHeader', function(editBox) local header = _G[editBox:GetName() .. 'Header'] if editBox:GetAttribute('chatType') == 'WHISPER' and header then _G[editBox:GetName() .. 'HeaderSuffix']:Hide() header:SetWidth(0) header:SetFormattedText(CHAT_WHISPER_SEND, (strsplit('-', editBox:GetAttribute('tellTarget')))) editBox:SetTextInsets(15 + (header:GetRight() or 0) - (header:GetLeft() or 0), 13, 0, 0) end end)
I tried using the code as a seperate addon, and Bugger encounters the same error with that same line.
__________________
-- Live like a King, laugh like his Jester. -- Last edited by Gryns : 09-25-15 at 09:22 AM. |
||
09-25-15, 02:24 PM | #14 |
Alright, the game is cutting off the string after "\0", which in retrospect I probably should have seen coming since it represents the end of a string.
Try this instead.. Lua Code:
|
|
09-26-15, 04:02 AM | #15 | |
Code:
ChatFrame_AddMessageEventFilter('CHAT_MSG_TEXT_EMOTES', function(self, event, msg, ...) return false, (msg:gsub('%f[^%z%s]([^\1-\64\91-\96\123-191]+)%-%u%l%a+%f[%z%s]', '%1')), ... end)
__________________
-- Live like a King, laugh like his Jester. -- |
||
09-26-15, 12:26 PM | #16 | |
%s matches any whitespace and %z essentially matches "nothing", which allows it to match the name if it's at the start or end of the message. So, since "Gryns-Aggramar" is surrounded by quotes and not spaces, the pattern fails. Add double-quotes to the frontier pattern to allow them to match. Lua Code:
|
||
09-27-15, 02:31 AM | #17 | |
But I looked up other character classes and tried some other combinations. But none of them seem to work. I'm trying to get the code to look for anything with a hyphen, and then remove the realm suffix. This is how I tried editing your code: Lua Code:
This apparently isn't working, and neither are the combinations %f[^-], %f[^%z-], %f[%z%s-]. Any idea how I should try to do it? Thanks again.
__________________
-- Live like a King, laugh like his Jester. -- |
||
09-27-15, 06:55 AM | #18 |
Without seeing exactly what it isn't working with I'm just taking a stab in the dark.
My best guess is it's putting some form of punctuation after the person's name. If you aren't concerned about it potentially matching something that isn't a name, you can just remove both %f[] patterns from the string and it would match anything that looks like "Name-Realm", regardless of what's around it, otherwise you can try this, which should cover any punctuation. Lua Code:
|
|
09-30-15, 09:43 AM | #19 | |
I also found a new tooltip addon that removes the suffixes from all existing tooltips, including pet and loot tooltips. Something I've been struggling with. It's called Cloudy Tooltip Mod. So my mission is nearing completion! The only thing that remains is to remove the floating name that appears when targeting a unit. This target name appears even if names are turned off completely. So far the only way I've been able to remove these, is by installing a nameplate addon like Tidy Plates, and turning the opacity of all nameplates to 0%. But that just feels like trying to kill a fly with a tank. In order for that to work I need to turn on all the unit nameplates, and then make them all see-through. And even then, when a unit is dead, it still shows the original floating name. Is there any subtle trick to hiding these names? Thanks again, Gryns
__________________
-- Live like a King, laugh like his Jester. -- |
||
09-30-15, 12:34 PM | #20 |
As far as I can tell there is no CVar for disabling your target's name.
Turning nameplates on is the only thing that hides it, and since nameplates aren't always visible (such as when it's dead or out of range) and the only other solution I can think of is removing the font entirely (which is used in other areas of the interface), I don't think this can reasonably be done. |
|
WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Getting rid of realm suffixes |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|