Quantcast Abbreviate Guild Names in Chat - ESOUI
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: 85
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.
__________________

Author of beloved and rejuvenated addons:

ShowMount             PvP FPS 2018

Notebook 2018         Junkee 2018

BestFriends 2018       New Addon
  Reply With Quote
05/27/19, 10:01 PM   #2
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 2,282
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: 85
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?
__________________

Author of beloved and rejuvenated addons:

ShowMount             PvP FPS 2018

Notebook 2018         Junkee 2018

BestFriends 2018       New Addon

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,263
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"
__________________
Like what I do? Support me on Patreon!
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  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: 85
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.
__________________

Author of beloved and rejuvenated addons:

ShowMount             PvP FPS 2018

Notebook 2018         Junkee 2018

BestFriends 2018       New Addon

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: 85
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
__________________

Author of beloved and rejuvenated addons:

ShowMount             PvP FPS 2018

Notebook 2018         Junkee 2018

BestFriends 2018       New Addon
  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