Hi there :]
In this tutorial, I will try to explain how to to make some dialog "animations",
but before that, some basic info :
#1 - This tutorial is (obviously) in *.html format, 'cause of it's many
advantages.
#2 - All code is placed inside <textarea> tags, and is READONLY, so
you don't have to worry about accidental overwrite of the code.
#3 - All code will automaticaly do the Select All part when clicking on
it, so all you have to do is do the Copy (Ctrl+C) part.
First step is to make a dialog (we need one if we are planning to animate
it :P). So let's do it. For our needs we will make one that has the same width
and height (it's easier to understand that way, we'll do the rectangular ones
too later). So, here's the dialog code :
(Danim like Dialog animation
:P)
OK, now that we've wrote our dialog and saw that it's good (no ID conflict,
nice layout, good functionality...) there is one little thing to do before
moving on. Change the size -1 -1 100 100 into size
-1 -1 1 1.
It will be explained later why.
Now, we have to write the basic alias for calling out
dialog. Normaly, I would do it this way :
This is actualy pretty good way for calling dialogs,
cause this way you are avoiding the * /dialog: 'Danim' name in use
error if dialog with that name already exists (it is done with if
($dialog(Danim)) part of code).
But, our alias will look like this :
You must be asking yourself why in heavens name would
I close and reopen dialog if it exists, instead of just bringing it to front/restoring
it. It can be done that way, but this way whenever dialog is called, it
will animate ;]
(this is just for tutorial purposes, I wouldn't do it that way for script.
Too much animations can be quite anoying).
And now, the very essence. The actual animation code.
Notice the while (%i <= 100) line, the
number 100 is the height and width of our dialog, so "%i"
variable depends from your dialog dimensions. Anyway, what do we do here
??
We are using a "while loop", and "dialog -s".
Cause I'm not the mIRC help file, nor is this tutorial, I will not explain
each command separately, you will have to do that yourself :]
Anyway, basicaly, I'm increasing the value of %i from 0
to 100, thus increasing the width and height of my dialog
from 0 to 100, meaning that I'm animating it. The parameters -srb
are for Size, Center dialog and DBU (dialog base units) in that order.
The aditional :
var %t 1 while (%t <= 80) inc %t
is here just to slow down the first while loop, cause without it, it just
runs so fast that you can hardly notice anything. You can change the value
of 80, to find out which speed suits your needs.
So, let's see how it works. copy/paste the Danim and dan.an alias and dialog
code into empty script file, then add this :
and save file as eg. danim.mrc (the
name of $script I will be using from now on, you may choose another one).
Now type "/danim" (without quotes), and POOF
! Magic ?? No, basic logic and scripting knowledge ;]
Why the timer ?? Why shouldn't we just put the dan.an alias
into the On Init event ?? Because my mIRC is acting quite
strange now, and it won't accept it that way, but if I do it with timer,
it works :P (you feel free to experiment)
And now is the right time to explain why we changed the size of our dialog
to 1 x 1. Well, if we left the size 100 x 100,
the dialog would first flash in it's full size, and then dissapeared to
nothing and started to grow (animate). This way we avoided that ;] (users
just love to find a bug in a script... so let's don't give 'em that pleasure).
Well, this would be the end of the first part of this tutorial. Here we
explained how to do the On Init animation. Now, it's time for some neat
tricks ;]
Trick 1 : animate the titlebar of your dialog
Hey, while we're here, let's animate the dialog titlebar also. It will take
longer for the actual dialog to appear, but it looks nice :]
So, here it is :
OK, for those who don't understand how this exactly
works, here's a brief explanation. First we need to find how long is our
titlebar text. We can always count character by character, or we can do
the :
//echo -a lenght is $len(Animate your dialogzz ;])
We see that it has 24 characters. Thats the value in our
first while loop. Dialog -t command changes the titlebar.
So, what we're doing is next :
We're "writing" the titlebar text letter by letter, from left to right,
using $left() identifier. (for more help, read mIRC Help,
"Text and Number Identifiers"). The second loop, the one with the
%t var is here again just to slow down the first one.
Now paste the dan.tbar alias into your danim.mrc
and change the dan.an alias into :
and type "/danim". See what I mean
?? :D
The titlebar animation will occure when (not before) the dialog animation
is finished. That is achieved by placing the .timer -m 1 1 dan.tbar
line AFTER the dialog animation code. This way, users can see everything,
first the dialog, and then the titlebar animation.
Trick 2 : animate the closing of dialog
While we're here, we can also make the dialog closing more nicer by adding
another animation. This time we're doing the growing animation reverse way,
meaning that we're decreasing the size from 100 x 100 to
1 x 1, and finaly closing it. Here's the code :
See what I mean ?? Nothing hard, just playing with with
basic dialog commands.
And all that is left is to add the sclick events and thats
it :D
Place this into your danim.mrc :
So, the full script file used for this example should
look like this :
Or, you can download the
Danim.mrc
here (right click, Save Target As).
Don't you just love mIRC scripting ??!? With a little of imagination and
effort, you can do bunch of stuff..
And now, as promised, the code for dialogs that don't have the same height/width
:
Basicaly, this one first does the animation stretching
the dialog horizontaly, and then verticaly. For example, if we have a dialog
called MyDialog that is 80 x 40, and we
want to animate it, the code will look like this :
All in all, you can just experiment with while's
and %var's. And it's fun to do it, cause you can make nice
stuff that way. Dialog animation can be a nice touch to even a mediocre
script, but don't get carried away. I know I would hate to wait like a whole
minute just to see a dialog for some basic script. Make your animations
nice and fast ;]
have fun :D
Some info about tutorial... |
|
First version release date :
|
3/25/2005 |
Current version release date : |
5/22/2008 |
Changes : |
1. Added some info about tutorial.
2. Changed the color pallete (replaced colored
with bold text).
3. Added example for rectangular dialog with dimensions.
4. Added "versions info".
5. Explained some parts better
6. Placed code in readonly <textarea> tags.
7. Made the code auto Select All
8. Remade in light/dark gray color pallete, to match the rest of site. |
Downloadable *.zip
version can be found here.
If you want, you can coment and/or rate it @ mirc.net
And that would be it :] |