ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Wish List (https://www.esoui.com/forums/forumdisplay.php?f=177)
-   -   [outdated] d() before chat is initialized (https://www.esoui.com/forums/showthread.php?t=6309)

sirinsidiator 05/29/16 02:29 AM

[outdated] d() before chat is initialized
 
Please consider the following change to the chat system, in order to allow debug messages to be shown from before EVENT_PLAYER_ACTIVATED.

Lua Code:
  1. function SharedChatSystem:Initialize(control, platformSettings)
  2.     self.cachedMessages = {}
  3. ...

Lua Code:
  1. function SharedChatSystem:AddMessage(text)
  2.     if IsChatSystemAvailableForCurrentPlatform() then
  3.         if(self.primaryContainer) then
  4.             self.primaryContainer:AddDebugMessage(text)
  5.         else
  6.             self.cachedMessages[#self.cachedMessages + 1] = text
  7.         end
  8.     end
  9. end

Lua Code:
  1. local function FlushMessageCache()
  2.     for i = 1, #self.cachedMessages do
  3.         self.primaryContainer:AddDebugMessage(self.cachedMessages[i])
  4.     end
  5.     self.cachedMessages = nil
  6. end
  7.  
  8. local function OnPlayerActivated()
  9.     playerActivated = true
  10.     TryLoadingSettings()
  11.  
  12.     if IsChatSystemAvailableForCurrentPlatform() then
  13.         if(not self.allowMultipleContainers) then
  14.             self:RedockContainersToPrimary()
  15.         end
  16.  
  17.         self:TryNotificationAndMailBursts()
  18.  
  19.         if(self.isAgentChatActive) then
  20.             self.agentChatBurstTimeline:PlayFromStart()
  21.         end
  22.     else
  23.         self.control:SetHidden(true)
  24.     end
  25.     FlushMessageCache()
  26. end

merlight 05/29/16 03:48 AM

The call to FlushCachedMessages should be in TryLoadSettings (after LoadChatFromSettings) so that it isn't called again. There's no need to call it again as long as primaryContainer exists, plus it will blow because you set the table to nil, and second call will try to iterate it. I'd set it to empty table to be safe.

sirinsidiator 05/29/16 04:04 AM

Right. Maybe also add a callback/hookpoint when the primary container is ready and the messages have not yet been flushed in order to make it easier for pChat's history restore feature to print the old messages.


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

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