Thread: Message Box
View Single Post
12-25-18, 02:14 PM   #3
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
Thanks, this helps, but I must be doing something wrong with either frame creation or setting the text. I've merged my code with yours and nothing is displayed. I did make sure that I do not have any favorite mounts and I had print statements to show me if I had logic errors. No errors. I am confused on the SetText function. Why call a function and isn't there a potential conflict with the name of the function? What am I missing?

Code:
--Addon will check to see if you have a favorite mount and remind you if you do not.

local JWNumMounts =  C_MountJournal.GetNumMounts();
local JWFav = 0
JWNoFav = CreateFrame("Frame", "JWNoFav", UIParent)
JWNoFavFont = [[Interface\Addons\SharedMedia_MyMedia\font\Lato-Regular.ttf]]
JWNoFavFontSize = 18
JWNoFavFontFlags = "NONE"

local function ShowMessage(text)
        if not JDoubleU00MessageBox then
			local f = CreateFrame("Frame", "JDoubleU00MessageBox", UIParent)
            --- Whatever your heart desires to see any messages plus a close (hide) button
			 f:SetFrameStrata("BACKGROUND")
			 f:SetWidth(128)
			 f:SetHeight(64)
			 f:SetPoint("CENTER",0,0)
	  
            function f:SetText(text)
			-- Depends on your frame setup above how the text is "set"
				nfText = f:CreateFontString("JWNoFavText", "OVERLAY", "NumberFontNormal") --GameFontNormal
				nfText:SetFont(JWNoFavFont, JWNoFavFontSize, JWNoFavFontFlags)
				nfText:SetPoint("CENTER", JWNoFav, "CENTER",0,1)
				nfText:SetText(text)
		    end
        end
        JDoubleU00MessageBox:SetText(text)
        if not JDoubleU00MessageBox:IsShown() then
            JDoubleU00MessageBox:Show()
        end
end

local function eventHandler(self, event, ...)
	for i = 1, JWNumMounts do
		if C_MountJournal.GetIsFavorite(i) then
			JWFav = JWFav + 1
		end
	end
	if JWFav == 0 then
		ShowMessage("You do not have any mounts selected as a favorite.")
	end
end

JWNoFav:RegisterEvent("PLAYER_ENTERING_WORLD")
JWNoFav:SetScript("OnEvent", eventHandler)
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote