Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:55 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.