Thread: Message Box
View Single Post
12-25-18, 02:52 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Your message FontString has a SetPoint of CENTER to your event frame which has no SetPoint. The SetText function was an "if needed" thought you might add to JDoubleU00MessageBox frame to set the text of its child FontString.

Lua Code:
  1. --Addon will check to see if you have a favorite mount and remind you if you do not.
  2.  
  3. local JWNumMounts =  C_MountJournal.GetNumMounts();
  4. local JWFav = 0
  5. JWNoFav = CreateFrame("Frame", "JWNoFav", UIParent)
  6. JWNoFavFont = [[Interface\Addons\SharedMedia_MyMedia\font\Lato-Regular.ttf]]
  7. JWNoFavFontSize = 18
  8. JWNoFavFontFlags = "NONE"
  9.  
  10. local function ShowMessage(text)
  11.     if not JDoubleU00MessageBox then
  12.         local f = CreateFrame("Frame", "JDoubleU00MessageBox", UIParent)
  13.             --- Whatever your heart desires to see any messages plus a close (hide) button
  14.         f:SetFrameStrata("BACKGROUND")
  15.         f:SetHeight(64)
  16.         f:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile="Interface/Tooltips/UI-Tooltip-Border", tile = true, tileSize = 8, insets = {left = 8, right = 8, top = 8, bottom = 8},})
  17.         f:SetBackdropColor(0.5, 1, 0.5)
  18.         f:SetBackdropBorderColor(1, 0, 0)
  19.         f:SetPoint("CENTER")
  20.  
  21.         f.Close = CreateFrame("Button", nil, f, "UIPanelButtonTemplate")
  22.         f.Close:SetSize(24, 24)
  23.         f.Close:SetPoint("TOPRIGHT", -8, -8)
  24.         f.Close:SetText("X")
  25.         f.Close:SetScript("OnClick", function(self) self:GetParent():Hide() end)
  26.  
  27.         f.nfText = f:CreateFontString("$parentText", "OVERLAY", "NumberFontNormal") --GameFontNormal
  28.         f.nfText:SetFont(JWNoFavFont, JWNoFavFontSize, JWNoFavFontFlags)
  29.         f.nfText:SetPoint("CENTER")
  30.     end
  31.     JDoubleU00MessageBox.nfText:SetText(text)
  32.     JDoubleU00MessageBox:SetWidth(JDoubleU00MessageBox.nfText:GetWidth() + 50)
  33.     if not JDoubleU00MessageBox:IsShown() then
  34.         JDoubleU00MessageBox:Show()
  35.     end
  36. end
  37.  
  38. local function eventHandler(self, event, ...)
  39.     for i = 1, JWNumMounts do
  40.         if C_MountJournal.GetIsFavorite(i) then
  41.             JWFav = JWFav + 1
  42.         end
  43.     end
  44.     if JWFav == 0 then
  45.         ShowMessage("You do not have any mounts selected as a favorite.")
  46.     end
  47. end
  48.  
  49. JWNoFav:RegisterEvent("PLAYER_ENTERING_WORLD")
  50. JWNoFav:SetScript("OnEvent", eventHandler)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-25-18 at 03:44 PM.
  Reply With Quote