ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Abbreviate Guild Names in Chat (https://www.esoui.com/forums/showthread.php?t=8556)

Phuein 05/27/19 08:23 PM

Abbreviate Guild Names in Chat
 
So, I've been trying for quite a while to get this working. The idea is simple:
Quote:

[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.

Baertram 05/27/19 10:01 PM

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

Phuein 05/28/19 09:50 AM

Quote:

Originally Posted by Baertram (Post 38215)
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?

sirinsidiator 05/28/19 10:04 AM

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"

Phuein 05/28/19 03:17 PM

Quote:

Originally Posted by sirinsidiator (Post 38221)
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.

Phuein 05/30/19 10:20 AM

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



All times are GMT -6. The time now is 08:32 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI