Thread Tools Display Modes
08-15-18, 06:38 PM   #1
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 61
Smile Fading Textures

I would like to fade a texture in, and then out, like a splash - I did it a while ago but cannot remember how. Doesn't have something to do with animation?

Please advise.

I added the Lua below for reference, I am really unsure how to get this to fade in/out. (edit)

Lua Code:
  1. local addonName, addonData = ...
  2.  
  3. local InstallerLogo = CreateFrame("Frame", addonName.."ILogo", UIParent);
  4. InstallerLogo.texture = InstallerLogo:CreateTexture(nil, "HIGH");
  5. InstallerLogo.texture:SetTexture("Interface\\Addons\\PawsUI\\Art\\Splash.tga");
  6. InstallerLogo.texture:SetAllPoints();
  7. InstallerLogo:RegisterEvent("PLAYER_ENTERING_WORLD");
  8. InstallerLogo:SetScript("OnEvent", function(self,event,...)
  9.     self:SetSize(850, 480);
  10.     self:SetPoint("CENTER");
  11. end)
  12. InstallerLogo:SetMovable(true)
  13. InstallerLogo:EnableMouse(true)
  14. InstallerLogo:RegisterForDrag("LeftButton")
  15. InstallerLogo:SetScript("OnDragStart", InstallerLogo.StartMoving)
  16. InstallerLogo:SetScript("OnDragStop", InstallerLogo.StopMovingOrSizing)
  17. -----------------------------------------------------
  18. InstallerLogo.animation = InstallerLogo:CreateAnimationGroup()
  19.  
  20. local a1 = InstallerLogo.animation:CreateAnimation("Alpha")
  21. a1:SetFromAlpha(0)
  22. a1:SetDuration(1)
  23. a1:SetToAlpha(1)
  24. InstallerLogo.animation:SetToFinalAlpha(true)

This makes the Logo not visible but does not fade. Perhaps it does fade but is immediate?

Last edited by candrid : 08-15-18 at 07:53 PM.
  Reply With Quote
08-15-18, 10:31 PM   #2
VincentSDSH
Non-Canadian Luzer!
 
VincentSDSH's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 350
UIFrameFadeIn()/Out() maybe? I use that in place of :Show()/:Hide() and it seems to work nicely.

Lua Code:
  1. UIFrameFadeIn(frame, timeToFade, startAlpha, endAlpha)
  2. UIFrameFadeOut(frame, timeToFade, startAlpha, endAlpha)
__________________
AddonsExecutive Assistant User Configurable To-Do ListLegible Mail Choose the Font for Your Mail
  Reply With Quote
08-16-18, 01:32 AM   #3
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 61
Originally Posted by VincentSDSH View Post
UIFrameFadeIn()/Out() maybe? I use that in place of :Show()/:Hide() and it seems to work nicely.

Lua Code:
  1. UIFrameFadeIn(frame, timeToFade, startAlpha, endAlpha)
  2. UIFrameFadeOut(frame, timeToFade, startAlpha, endAlpha)
Hm, perhaps. Is there a way in Lua perhaps? I'm uncomfortable with XML. Trying to stay simple.

Lua Code:
  1. local addonName, addonData = ...
  2. local InstallerLogo = CreateFrame("Frame", addonName.."ILogo", UIParent);
  3. InstallerLogo:RegisterEvent("PLAYER_ENTERING_WORLD");
  4. InstallerLogo:SetScript("OnEvent", function(self,event,...)
  5.     self:SetSize(850, 480); -- the size of the splash
  6.     self:SetPoint("CENTER"); -- its position on the screen
  7.     if type(CharacterVar) ~= "number" then
  8.         CharacterVar = 1
  9.         InstallerLogo.texture = InstallerLogo:CreateTexture(nil, "HIGH");
  10.         InstallerLogo.texture:SetTexture("Interface\\Addons\\PawsUI\\Art\\Splash.tga");
  11.         InstallerLogo.texture:SetAllPoints();
  12.         InstallerLogo:SetAlpha(0)
  13.         InstallerLogo:SetMovable(true)
  14.         InstallerLogo:EnableMouse(true)
  15.         InstallerLogo:RegisterForDrag("LeftButton")
  16.         InstallerLogo:SetScript("OnDragStart", InstallerLogo.StartMoving)
  17.         InstallerLogo:SetScript("OnDragStop", InstallerLogo.StopMovingOrSizing)
  18.     else
  19.         if CharacterVar == 1 then
  20.             -- Do something post install. --
  21.         else
  22.             -- Do something post install. --
  23.         end
  24.         CharacterVar = CharacterVar + 1
  25.         if CharacterVar == 100 then
  26.             ChatFrame1:AddMessage('HOLY CRAP'.. UnitName("Player").."! You have used PawsUI *100* times before. THANK YOU! <3")
  27.         else
  28.             -- Do nothing. --
  29.         end
  30.     end
  31. end)

Ok, so this is what I have so far in the goal to fade in/out the splash minus that part. This part is trying to set a per character variable to 1. On 1 or below, the splash shows, 2 or higher - it doesn't. I don't want the splash / install to pop up on every loading screen / reloadui.

Last edited by candrid : 08-16-18 at 02:17 AM.
  Reply With Quote
08-16-18, 02:30 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
This is the frame fader I use in rLib which is using animations.
https://github.com/zorker/rothui/blo...framefader.lua
Example call from one of my addons:
https://github.com/zorker/rothui/blo...r/core.lua#L48

If you need an example for a drag frame you can check rLib too.
https://github.com/zorker/rothui/blo.../dragframe.lua
https://github.com/zorker/rothui/blo.../core.lua#L107
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 08-16-18 at 02:32 AM.
  Reply With Quote
08-16-18, 03:27 AM   #5
VincentSDSH
Non-Canadian Luzer!
 
VincentSDSH's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 350
Originally Posted by candrid View Post
Hm, perhaps. Is there a way in Lua perhaps? I'm uncomfortable with XML. Trying to stay simple.
Wha? UIFrameFadeIn() and UIFrameFadeOut() are function calls, you can call them from Lua or XML. Instead of frame:Show() you do UIFrameFadeIn(frame, timeToFade, startAlpha, endAlpha) and vice-versa.
__________________
AddonsExecutive Assistant User Configurable To-Do ListLegible Mail Choose the Font for Your Mail
  Reply With Quote
08-16-18, 04:47 AM   #6
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 61
Originally Posted by VincentSDSH View Post
Wha? UIFrameFadeIn() and UIFrameFadeOut() are function calls, you can call them from Lua or XML. Instead of frame:Show() you do UIFrameFadeIn(frame, timeToFade, startAlpha, endAlpha) and vice-versa.
Right, I figured that out a short while later. I thought I included that in my edit. Sorry that I did not.
  Reply With Quote
08-16-18, 05:11 AM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
If you only want it to show up on the first time you log in ...

PlayerEnteringWorld has two parameters. firstTimeLogin, reload

If the first parameter is true then it is the first time you have logged into the game and can show the splash.


Now, if you also only want it to show up if it is the first time that version of the addon has been run, to show say update notes, then you could then have an account or character specific SavedVariable setting that holds the last version number loaded and then only display if that value is different from the one now running. Then after the frame is displayed update the saved variable.

Something like the following
Lua Code:
  1. if firstTimeLogin and sv.version ~= addon.version then
  2.    welcomeFrame:Show() or UIFrameFadeIn(welcomeFrame,1,0,1)
  3.    sv.version = addon.version
  4. end
__________________
  Reply With Quote
08-16-18, 05:56 AM   #8
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
I can't see you calling :Play() anywhere in your code. Animations don't run automatically.
Lua Code:
  1. InstallerLogo.animation:Play()
Using the built-in UIFrameFadeIn/UIFrameFadeOut has potential to spread taint, because it's adding your frame to a tracking table.
__________________

Last edited by MunkDev : 08-16-18 at 05:59 AM.
  Reply With Quote
08-16-18, 08:20 AM   #9
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 61
Originally Posted by zork View Post
This is the frame fader I use in rLib which is using animations.
https://github.com/zorker/rothui/blo...framefader.lua
Example call from one of my addons:
https://github.com/zorker/rothui/blo...r/core.lua#L48

If you need an example for a drag frame you can check rLib too.
https://github.com/zorker/rothui/blo.../dragframe.lua
https://github.com/zorker/rothui/blo.../core.lua#L107
I understand most of it but what is the "rlib" about? Can that be substituted?
Lua Code:
  1. rLib:CreateFrameFader(ObjectiveTrackerFrame, cfg.fader)
  Reply With Quote
08-16-18, 08:21 AM   #10
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 61
Originally Posted by Xrystal View Post
If you only want it to show up on the first time you log in ...

PlayerEnteringWorld has two parameters. firstTimeLogin, reload

If the first parameter is true then it is the first time you have logged into the game and can show the splash.


Now, if you also only want it to show up if it is the first time that version of the addon has been run, to show say update notes, then you could then have an account or character specific SavedVariable setting that holds the last version number loaded and then only display if that value is different from the one now running. Then after the frame is displayed update the saved variable.

Something like the following
Lua Code:
  1. if firstTimeLogin and sv.version ~= addon.version then
  2.    welcomeFrame:Show() or UIFrameFadeIn(welcomeFrame,1,0,1)
  3.    sv.version = addon.version
  4. end
I had no idea it had parameters.
  Reply With Quote
08-16-18, 08:22 AM   #11
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 61
Originally Posted by MunkDev View Post
I can't see you calling :Play() anywhere in your code. Animations don't run automatically.
Lua Code:
  1. InstallerLogo.animation:Play()
Using the built-in UIFrameFadeIn/UIFrameFadeOut has potential to spread taint, because it's adding your frame to a tracking table.
Awesome, thank you. I definitely want to avoid taint.
  Reply With Quote
08-16-18, 08:37 AM   #12
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 61
Originally Posted by Xrystal View Post
Something like the following
Lua Code:
  1. if firstTimeLogin and sv.version ~= addon.version then
  2.    welcomeFrame:Show() or UIFrameFadeIn(welcomeFrame,1,0,1)
  3.    sv.version = addon.version
  4. end
I am sorry to ask but could you elaborate on this example? I do not understand the sv.version segment. Also, in many versions of my code here, offline I cannot get the SavedVariablesPerCharacter to do anything.
  Reply With Quote
08-16-18, 09:29 AM   #13
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
rLib is a library addon that has generic functions used by many of my addons.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
08-16-18, 10:03 AM   #14
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 61
Originally Posted by zork View Post
rLib is a library addon that has generic functions used by many of my addons.
Thank you, I really admire your work BTW.
  Reply With Quote
08-16-18, 11:38 AM   #15
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Originally Posted by candrid View Post
I am sorry to ask but could you elaborate on this example? I do not understand the sv.version segment. Also, in many versions of my code here, offline I cannot get the SavedVariablesPerCharacter to do anything.

Originally Posted by Xrystal View Post
Something like the following
Lua Code:
Lua Code:
  1. if firstTimeLogin and sv.version ~= addon.version then
  2.    welcomeFrame:Show() or UIFrameFadeIn(welcomeFrame,1,0,1)
  3.    sv.version = addon.version
  4. end
The SavedVariablesPerCharacter section in the toc file will create a table of that name in the WTF\Account\<AccountName>\<ServerName>\<CharacterName>\SavedVariables\<addonName>.lua file.

sv.version is just an example of variable ( item in the savedvariable table) connected to the sv value which is just what I put to show that you use your savedvariable table in place of sv.

addon.version is a similar thing but is just pointing to a variable in your addon code holding a copy of your addon version which can be retrieved using GetAddOnMetadata function as the following example shows.

<...> shows what has to be replaced with what is your addon's equivalent

Lua Code:
  1. local function OnEvent(self,event,...)
  2.    -- create variables from the event arguments
  3.    local login,reload = ...
  4.    -- if this is the first time entering the world
  5.    if event == "PLAYER_ENTERING_WORLD" and login == true then
  6.       local version = GetAddOnMetadata(<addonName>, "Version"))
  7.       if version ~= <SavedVariablePerCharacterTable>.version then
  8.          <Show Your Splash Frame and fill any of the UI with its required data>
  9.          -- Then Update the saved variable table for the character with the new version
  10.          <SavedVariablePerCharacterTable>.version = version
  11.      end
  12.   end
  13. end

You may also get away with using PLAYER_LOGIN which should only happen the first time you log in. But it would depend on what information you need and its availability at that time. PLAYER_ENTERING_WORLD tends to be the event used for this reason so thankfully they have added those two parameters to the event to make things easier to identify between a fresh login and a reload/loading screen.


I hope that helps make a bit more sense of what I was trying to explain.
__________________
  Reply With Quote
08-16-18, 08:04 PM   #16
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 61
It does Xrystal. Thank you, I will try and get it working.
  Reply With Quote
08-16-18, 08:16 PM   #17
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 61
Originally Posted by Xrystal View Post
I hope that helps make a bit more sense of what I was trying to explain.
Lua Code:
  1. local addonName, addonData = ...
  2. local function OnEvent(self,event,...)
  3.       -- create variables from the event arguments
  4.     local login,reload = ...
  5.         -- if this is the first time entering the world
  6.         if event == "PLAYER_ENTERING_WORLD" and login == true then
  7.            local version = GetAddOnMetadata(PawsUI, "Version")
  8.             if version ~= addon.version then
  9.  
  10.               -- <Show Your Splash Frame and fill any of the UI with its required data>
  11.             local InstallerLogo = CreateFrame("Frame", addonName.."ILogo", UIParent);
  12.             InstallerLogo:RegisterEvent("PLAYER_ENTERING_WORLD");
  13.             InstallerLogo:SetScript("OnEvent", function(self,event,...)
  14.                 self:SetSize(850, 480); -- the size of the splash
  15.                 self:SetPoint("CENTER"); -- its position on the screen            
  16.                 UIFrameFadeIn(InstallerLogo,1,0,1);
  17.             end)  
  18.               -- Then Update the saved variable table for the character with the new version
  19.               addon.version = version
  20.             end
  21.         end
  22.     end

So if I wrote it like this it would get the addon version when loaded. Compare it to the saved variable with is in PawDB - Then show the splash if it didn't equal 2. Then make it equal 2?

Headaches are the worst for learning.

EDIT - fixed my code. PawsUI.lua inside saved variables still shows PawDB = nil

Last edited by candrid : 08-16-18 at 08:38 PM.
  Reply With Quote
08-16-18, 09:57 PM   #18
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
You have to initialise your saved variables .. by default they will be nil.

Near the top of your addon's lua file you need set the base values

-- This will create a new table containing no values
<SavedVariablePerCharacterTable> = {}

-- This will set the version variable to nil so that the first test will cause the splash to appear.
<SavedVariablePerCharacterTable>.version = nil

By the time PLAYER_ENTERING_WORLD is called your saved variables should be loaded in memory

So, using your example you posted this is how I would code it. See how this works out for you. Login a few times without changing the Version field in the TOC and then a few times after changing it ... the splash should only appear after it is changed.

Lua Code:
  1. local addonName, addonData = ...
  2.  
  3. -- Force initialisation in case there are no saved variables yet
  4. -- These should get overriden when the saved variables are loaded
  5. PawDB = {}
  6. PawDB.version = nil
  7.  
  8. -- Event function
  9. local function OnEvent(self,event,...)
  10.  
  11.       -- create variables from the event arguments
  12.       local login,reload = ...
  13.  
  14.         -- if this is the first time entering the world
  15.         if event == "PLAYER_ENTERING_WORLD" and login == true then
  16.            local version = GetAddOnMetadata("PawsUI", "Version")
  17.             if version ~= PawDB.version then
  18.                 -- Show the Splash Frame and fill any of the UI with its required data
  19.                 self:SetSize(850, 480); -- the size of the splash
  20.                 self:SetPoint("CENTER"); -- its position on the screen            
  21.                 UIFrameFadeIn(self,1,0,1);
  22.  
  23.                 -- Then Update the saved variable table for the character with the new version
  24.                 PawDB.version = version
  25.            end
  26.       end
  27.  end
  28.  
  29. -- Create the frame and set which events to monitor and which function will respond to it
  30. local InstallerLogo = CreateFrame("Frame", addonName.."ILogo", UIParent);
  31. InstallerLogo:RegisterEvent("PLAYER_ENTERING_WORLD");
  32. InstallerLogo:SetScript("OnEvent", OnEvent)
__________________
  Reply With Quote
08-17-18, 06:39 AM   #19
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 61
I literally tried that code as shown and the splash does not show. I am unsure why. I am really sorry to bother you guys with this.

Any idea why? I changed the version numbers around in the toc.
  Reply With Quote
08-17-18, 06:54 AM   #20
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Just noticed, you haven't given your frame a visual presence. You need to give it a backdrop or background texture/color to visually see it. However, using /framestack will allow you to see where it would be if it was viewable.

I'll just code up a quick mini addon to make sure it does do what I expect and then I'll post it up for you.


Edit: Spotted some other boo boos so will rig up a quick and dirty version for you to use as an example
__________________

Last edited by Xrystal : 08-17-18 at 07:03 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Fading Textures

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