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, 03:27 AM   #4
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   #5
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   #6
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, 02:30 AM   #7
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, 08:20 AM   #8
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, 05:56 AM   #9
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:22 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 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, 09:29 AM   #11
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   #12
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, 08:04 PM   #13
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-17-18, 06:39 AM   #14
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   #15
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
08-17-18, 07:58 AM   #16
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Okay, this is the barest minimum I needed to get it to work. The fading code used is simply due to its simplicity. I am personally using animation fading in my big project so I'll leave any changes you require up to you.

<YourAddonName>.TOC
Code:
## Interface: 80000
## Title: <YourAddOnName>
## Notes: Shows a Splash Window
## Version: 1.0.7
## Author: Whoever wants to use it honest
## eMail: contactme@myemailaddress
## DefaultState: Enabled
## RequiredDeps: 
## LoadOnDemand: 0
## SavedVariables: 
## SavedVariablesPerCharacter:  PawDB

<YourAddOnName>.lua

<YourAddOnName>.lua
Lua Code:
  1. local addonName, addonData = ...
  2.  
  3. -- Create a new table if it is empty
  4. addonData = addonData or {}
  5.  
  6. -- Get this version of the addon
  7. addonData.version = GetAddOnMetadata(addonName, "Version")
  8.  
  9. -- Force initialisation in case there are no saved variables yet
  10. -- These should get overriden when the saved variables are loaded
  11. PawDB = {}
  12. PawDB.version = nil
  13.  
  14. -- Create the frame and set up its visual details, I've just created a white background
  15. -- By Default it will show so FadeOut immediately via the method you choose
  16. local InstallerLogo = CreateFrame("Frame", addonName.."ILogo", UIParent);
  17. InstallerLogo.Background = InstallerLogo:CreateTexture( "$parentBackground", "BACKGROUND" );
  18.  
  19. -- Create UI Elements
  20. InstallerLogo.Background:SetAllPoints()
  21.  
  22. -- Customize the Elements
  23. InstallerLogo.Background:SetColorTexture(1,1,1,1)
  24.  
  25. -- Fade Out the screen as we don't want to see it by default
  26. UIFrameFadeOut(InstallerLogo,1,1,0)
  27.  
  28. -- Event function
  29. local function OnEvent(self,event,...)
  30.    
  31.     -- if this is the first time entering the world
  32.     if event == "PLAYER_ENTERING_WORLD" then
  33.         local login,reload = ...
  34.        
  35.         -- Displays the two values in the chat frame so you can see what is being tested
  36.         --print(addonData.version, PawDB.version)
  37.  
  38.         -- Only process this block if this is the first time logging in and the version numbers are different
  39.         -- Addons will only know about a TOC change if the change was made before you logged into the game ( character screen is not enough, log right out to the beginning)
  40.         if login == true and addonData.version ~= PawDB.version then
  41.  
  42.             -- Set up the Splash Screens UI with its required data and any other changes not already made
  43.             InstallerLogo:SetSize(850, 480); -- the size of the splash
  44.             InstallerLogo:SetPoint("CENTER"); -- its position on the screen            
  45.  
  46.             -- Then fade it into view using your preferred method
  47.             UIFrameFadeIn(InstallerLogo,1,0,1);
  48.  
  49.             -- Then Update the saved variable table for the character with the new version
  50.             PawDB.version = addonData.version
  51.        end
  52.     end
  53.  end
  54.  
  55.  
  56. -- Create the frame that will monitor events and tell the other frames what to do
  57. local EventWatcher = CreateFrame("Frame")
  58. EventWatcher:RegisterEvent("PLAYER_ENTERING_WORLD");
  59. EventWatcher:SetScript("OnEvent", OnEvent)
__________________
  Reply With Quote
08-17-18, 08:55 AM   #17
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 61
Thank you! I will get it a combing.
  Reply With Quote
08-19-18, 12:52 AM   #18
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Someone mentioned that PLAYER_ENTERING_WORLD now returns two args that show if its a login or sth else.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  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