Quantcast
How to change alignment of alert texts
I have moved alert text notifications from the top right corner to the top left corner (using the Azurah addon). With the default alignment to the right it looks just weird, so this is my solution how to change alignment:
(just copy&paste the code to the end of any .lua file in your addons folder)

Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("Modify_AlertTextNotification", EVENT_ADD_ON_LOADED,
  2.    function(eventCode, addon)
  3.       if (addon):find("^ZO_") then return end --run this code after default UI is loaded
  4.      
  5.       local line = ZO_AlertTextNotification:GetChild(1)
  6.       if not line then
  7.          ZO_Alert(UI_ALERT_CATEGORY_ALERT, nil, " ")
  8.          line = ZO_AlertTextNotification:GetChild(1)
  9.       end
  10.       line.fadingControlBuffer.anchor = TOPLEFT
  11.      
  12.       function line.fadingControlBuffer.templates.ZO_AlertLine.setupFunction(control, category, message, color, soundId)
  13.          control:SetWidth(ZO_Compass:GetLeft() - GuiRoot:GetLeft() - 40)
  14.          control:SetText(message)
  15.          control:SetColor(color:UnpackRGBA())
  16.          control:SetHorizontalAlignment(TEXT_ALIGN_LEFT)
  17.  
  18.          ZO_SoundAlert(category, soundId)
  19.       end
  20.      
  21.       EVENT_MANAGER:UnregisterForEvent("Modify_AlertTextNotification", eventCode)
  22.    end)