Thread Tools Display Modes
05/27/19, 08:23 PM   #1
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 132
Post Abbreviate Guild Names in Chat

So, I've been trying for quite a while to get this working. The idea is simple:
[My Guild Name] [@bob]: Hey guys.

... turns into ...

[MGN] [@bob]: Hey guys.

I've tried prehooking to the CHAT_SYSTEM, EVENT_CHAT_MESSAGE_CHANNEL event. I've tried prehooking to CHAT_SYSTEM.primaryContainer, "AddMessageToWindow". I even tried changing the guild names in the CHAT_SYSTEM table.

All approaches crash miserably. Any changes to the guild name makes the game very unhappy. No error, just freeze.

So, I'm a bit stumped. Any good approach on getting this done? Without redoing the whole chat system.
  Reply With Quote
05/27/19, 10:01 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Did you have a look at pChat? I think it got such a feature to rename the guilds to short forms.
But I also know pChat overwrites and changes a lot of chat stuff so better not "doing the totally same" :-)
Visit the devs here and ask the question, I bet someone is able to help: https://gitter.im/esoui/esoui
  Reply With Quote
05/28/19, 09:50 AM   #3
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 132
Originally Posted by Baertram View Post
Did you have a look at pChat? I think it got such a feature to rename the guilds to short forms.
But I also know pChat overwrites and changes a lot of chat stuff so better not "doing the totally same" :-)
Visit the devs here and ask the question, I bet someone is able to help: https://gitter.im/esoui/esoui

Sadly, pChat overwrites the whole chat system. Which is exactly what I want to avoid. It's no surprise that it doesn't even run for me, as it's out of date and is so vulnerable to API changes. (It even relies on libChat2 from 2015, yikes.)

I went over its code again now, just to make sure. (6.4k code lines in one file.) I see the option of overriding the guild name, but that (changing guild names in the CHAT_SYSTEM table) didn't work for me [when not overwriting the API.]

Any other ideas, anybody?

Last edited by Phuein : 05/28/19 at 10:02 AM.
  Reply With Quote
05/28/19, 10:04 AM   #4
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,566
Looking through the code, it seems the game is using the method GetChannelName to determine what guild name to show. It uses the information in chatdata.lua to that end. You could try to overwrite the channel info so it no longer uses a dynamic name for the guild channels and then set your custom name like this:

Lua Code:
  1. local ChannelInfo = ZO_ChatSystem_GetChannelInfo()
  2. local channelId = CHAT_CHANNEL_GUILD_1
  3. ChannelInfo[channelId].dynamicName = false
  4. ChannelInfo[channelId].name = "MyCustomGuildName"
  Reply With Quote
05/28/19, 03:17 PM   #5
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 132
Originally Posted by sirinsidiator View Post
Looking through the code, it seems the game is using the method GetChannelName to determine what guild name to show. It uses the information in chatdata.lua to that end. You could try to overwrite the channel info so it no longer uses a dynamic name for the guild channels and then set your custom name like this:

Lua Code:
  1. local ChannelInfo = ZO_ChatSystem_GetChannelInfo()
  2. local channelId = CHAT_CHANNEL_GUILD_1
  3. ChannelInfo[channelId].dynamicName = false
  4. ChannelInfo[channelId].name = "MyCustomGuildName"

Tried that. It just changes the table data in CHAT_SYSTEM, which freezes the game (and/or messes guild functionality) at some eventual point. I assume it uses this data somewhere else and tries to match it.

Last edited by Phuein : 05/29/19 at 07:27 AM.
  Reply With Quote
05/30/19, 10:20 AM   #6
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 132
Post

I've come to a solution. Not ideal, as I override a global function, but it's a very specific one-liner. This lets me affect the channel links (which only seem to apply to the chat box, and to this specific usage) without changing any data tables.

Code:
_G["ZO_LinkHandler_CreateChannelLink"] = CreateChannelLink
Code:
local OriginalCreateChannelLink = _G["ZO_LinkHandler_CreateChannelLink"]
local function CreateChannelLink(channelName)
	-- Disabled.
	if not Junkee.savedVars.shortGuildNames then return OriginalCreateChannelLink(channelName) end

	local name = channelName

	for i = CHAT_CHANNEL_GUILD_1, CHAT_CHANNEL_GUILD_5 do
		if GetChannelName(i) == channelName then
			-- Get only the intials.
			name = name:gsub("(%a)%w*", function(l) return l end)
			-- Remove the spaces.
			name = name:gsub("%s+", "")
		end
	end

	-- Only change the appearance, not the data.
	return ZO_LinkHandler_CreateLink(name, nil, CHANNEL_LINK_TYPE, channelName)
end
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Abbreviate Guild Names in Chat

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off