Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 06-25-2008, 02:47 AM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
I like it because it's simple.
Reply With Quote
  #3  
Old 06-25-2008, 02:52 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I'm not a fan of your coding style, but it's personal preference I guess

Nice script
__________________
Reply With Quote
  #4  
Old 06-25-2008, 02:53 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
Quote:
Originally Posted by cbk1994 View Post
I'm not a fan of your coding style, but it's personal preference I guess
Heh, guess I deserved that one..
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #5  
Old 06-25-2008, 03:18 AM
TheStan TheStan is offline
Stan?
Join Date: May 2008
Location: U.S.
Posts: 100
TheStan is on a distinguished road
Send a message via AIM to TheStan Send a message via MSN to TheStan
Quote:
Originally Posted by DrakilorP2P View Post
I like it because it's simple.
I've seen something like this done with a class joined to a gui control. For some reason I feel that that's a bit more organized/simpler/better. I can't find the right word to explain it, but something about that way strikes me better than the way Ziro did it.

Quote:
Originally Posted by xXziroXx View Post
Heh, guess I deserved that one..
An excellent script nontheless tho buddy!
Reply With Quote
Reply


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 10:49 AM.


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