Thread Tools Display Modes
05/29/16, 02:29 AM   #1
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
[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
 
05/29/16, 03:48 AM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
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.
 
05/29/16, 04:04 AM   #3
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
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.
 

ESOUI » Developer Discussions » Wish List » [outdated] d() before chat is initialized

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