Thread: GuiCtrl Fader
View Single Post
  #1  
Old 06-25-2008, 02:39 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
GuiCtrl Fader

Uses alpha in order to fade it in and out depending on if you're hovering your mouse over the GuiCtrl or not.

Complete script, with a GuiWindowCtrl included as example on usage.

PHP Code:
//#CLIENTSIDE
function onCreated()
{
  new 
GuiWindowCtrl("ExampleGui") {
    
alpha this.baseAlpha .3;
    
    
thiso.catchevent(this"onMouseEnter""onMouseEnter");
    
thiso.catchevent(this"onMouseLeave""onMouseLeave");
  }
}

function 
onMouseEnter(objscheduleevent(.05"FadeGUI""setValue"obj1);
function 
onMouseLeave(objscheduleevent(.05"FadeGUI""setValue"objobj.baseAlpha);

function 
onFadeGUI(modeobjvalue)
{
  
// mode: 'setValue' or 'changeAlpha'
  // obj: GuiCtrl or name of GuiCtrl
  // value: Alpha to reach

  
temp.modifier .1// How much should the alpha change every 0.05 seconds?
  
  // Let's lets make sure that 'obj' really is a GuiCtrl, shall we?
  
if (obj.name == "obj") {
    
// If the GuiCtrl exists, we got it!
    
with ((@obj)) obj this;
    
    
// Can't change alpha on a TGraalVar!
    
if (obj.objecttype() == "TGraalVar") return;
  }
  
  
// Tadaa!
  
if (mode == "setValue") {
    
cancelEvents("changeAlpha");
    
obj.targetAlpha value;
    
scheduleevent(.05"FadeGUI""changeAlpha"obj);
  } else if (
mode == "changeAlpha") {
    if (
obj.alpha != obj.targetAlpha) {
      if (
obj.alpha obj.targetAlphaobj.alpha -= temp.modifier;
      else if (
obj.alpha obj.targetAlphaobj.alpha += temp.modifier;
      
scheduleevent(.05"FadeGUI""changeAlpha"obj);
    } else 
cancelEvents("changeAlpha");
  }

As always, please, use the forums reputation system to show if you like the script or not. Don't hesitate to leave your name saying who you are, I won't "strike back" if you give me negative rep!
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote