Welcome to my MDX tutorial, now in this tutorial I will cover a region of different examples from: toolbar to MP3 player.
Starting:
What you need to
get started
1) This tutorial
2) MDX
3) A little bit of time.
Aliases needed:
alias mdx { return path-to-mdx/mdx.dll }
alias ctl { return path-to-ctl/ctl_gen.mdx }
alias bars { return path-to-bars/bars.mdx }
alias views { return path-to-views/views.mdx }
alias dmu { return path-to-dmu/dmu.dll }
alias mdx.load { dll $mdx SetMircVersion $version | dll $mdx MarkDialog $dname
}
Use the last alias to make the MDX load up easier and quicker, and it looks
nicer too.
Thats all we need at the moment, if you look at the bottom of this tutorial
you will notice all the URL's to the DLL's.
1) MP3 Player
Right, with a simple MP3 player, we will use webdings (4:;9<)
to create those characters.
Example:
dialog mp3 {
title "Test MP3"
size -1 -1 112 51
option dbu
edit "Song.mp3", 1, 4 2 50 10, autohs center
edit "3m22s", 2, 4 13 50 10, autohs center
text "", 3, 5 24 103 8
button "4", 4, 5 35 21 12
button "<", 5, 26 35 21 12
button ";", 6, 47 35 21 12
button ":", 7, 68 35 21 12
button "9", 8, 89 35 21 12
edit "00:00", 9, 54 2 55 20, autohs center
}
Ok, now I take
it for example you know dialogs to a certain degree. Right, now lets begin with
the init.
on *:dialog:mp3:init:0: {
dll $mdx SetMircVersion $version
dll $mdx MarkDialog $dname
dll $mdx SetControlMDX $dname 3 ProgressBar smooth > $ctl
dll $mdx SetFont $dname 4,5,6,7,8 -10 400 Webdings
dll $mdx SetFont $dname 9 -22 400 Verdana
}
Right, now i'll explain each section piece by piece.
1) This is sub-standard mdx, you have to make sure it knows what version of
mIRC you're using
2) It will mark the dialog with MDX
3) This is the control of the progress bar, which uses text fields, i'll explain
each item seperately later
4) This sets the font of the ID's (4,5,6,7,8) to size 10 Webdings
5) This sets the font of the ID's (9) to size 22 Verdana
And before it would've looked like:
And with MDX:
Now you see how easy that was? I'll give you the information if you want the
progress bar to go up, that is fairly easy to do too. Add this alias: alias
update.pbar { did -ra mp3 14 $int($calc($calc($insong.pos / 1000) / $calc($insong.length
/ 1000) * 100)) }
And you would use it in the splay ID. Eg: on *:dialog:mp3:sclick:*: { if ($did
== idofplaybutton) { splay -p mp3 | timer 0 1 update.pbar } }
and that would upgrade the pbar, but remember to do: timer1 off other wise it
would never end and you would flood off :).
Now, something a little bit harder, a toolbar, I know alot of you would like
to learn how to make one, and I learnt thanks to [K]Freak. Ok, this is my toolbar,
its pretty straight forward:
2) Toolbar
dialog toolbar {
title "Toolbar"
size 1 1 1024 3
button "ahaha", 45, 0 0 1 1, hide default ok
list 3, 2 4 1024 30, size
}
Ok, as usual it was easy..now on to the init, and in a toolbars case it is really
confusing at times, so here we go!
on *:dialog:toolbar:init:0: {
dll $mdx SetMircVersion $version
dll $mdx MarkDialog $dname
dll $mdx SetControlMDX $dname 3 ToolBar list arrows flat wrap nodivider >
$bars
dll $mdx SetBorderStyle 3
dll $mdx SetDialog toolbar style
did -i $dname 3 1 bmpsize 16 16
did -i $dname 3 1 setimage icon small $icons(Driven~4.ico)
did -i $dname 3 1 setimage icon small $icons(Driven~3.ico)
did -a $dname 3 +a 1 $chr(32) $+ $chr(9) $+ Connect
did -a $dname 3 +a 2 $chr(32) $+ $chr(9) $+ Disconnect
did -a $dname 3 -
echo -a $dll($dmu,BarAdd,toolbar > $dname)
}
Ok, well thats it! Thats the hard part, now to explain
1) Sets mIRC Version onto mdx
2) Marks the dialog for MDX
3) Sets the control so that it: lists it, wraps text to the right of icons,
arrows (+v) no divider so you don't get that two pixel line above it
4) Sets the border to style 3
5) Removes the toolbar at the top (with the [X])
Ok, the difficult part is coming:
6) Makes it set the image size to 16 x 16, if you wanted to you could increase
this to 32 32 but make sure you change "small" to "large"
7) Sets the image to Driven~4.ico (with alias : alias icons { return path-to-icons/
$+ $1- } - thanks [K]Freak :P)
8) Same as above but Driven~3.ico
9) Now this sets a tooltip of: "Connect" if you where to add text
to: $chr(32) $+ Moo $+ $chr(9) $+ Connect it would look like:
But without the "Mooo" in the $chr(32) $+ $chr(9) Connect it returns
just the tooltip "Connect" with no "Mooo"
10) Its the same for the disconnect icons
11) "-" add a spacer (as seen on the SS) and add spaces to space every
item out properly.
Now when clicking them, because they're a list you have to do:
on *:dialog:toolbar:sclick:3: {
var %r = $did(3,toolbar).sel
if (%r == 1) { echo -a moooo }
} etc, but be warned the "-" makes one space.
Note: Where it says: did -a $dname 3 +a 1, always + 1 when you're going up,
except for spacers, but watch out, it can be confusing.
And thats how you do a toolbar, thats about as hard as that gets, my idea is
a little bit rusty, but the best place to look would be at [K]freaks tutorial
here
3) Misc MDX items
i) Progress bars.
When making progress bars, its easy to remember that to add information you
have to use a timer, now its easy to remember also, that a progress bar is jus'
a modified text field, so you still have to add "did -a $dname <id>"
so its quite easy, here we go:
Dialog:
Just a simple text field (enlarged) and MDX'd up, now the way to do this, thanks
to my good friend Joe Honer (Triple-H) he gave me this alias, i'll show you
all code:
dialog prog {
title "progress bar"
size -1 -1 129 44
option dbu
text "", 1, 31 32 57 8
text "", 2, 1 8 126 16
}
init:
on *:dialog:prog:init:0: {
mdx.load
dll $mdx SetControlMDX $dname 2 ProgressBar smooth > $ctl
load.up
}
Alias to make counter work:
alias load.up {
dialog -m prog prog
var %dsg = 0
while (%dsg <= 100) {
inc %dsg
.timer -m 1 $calc(25 * %dsg) .did -a prog 2 %dsg 0 100
}
}
try it if you wish :) its quite good, can be used for purposes such as: loading
scripts, if you have made an addon, make it so that it loads, or if you require
a download of some sort..Its quite fun and jus' makes thigns look decent :)
ii) Colouring Dialogs / text / bg's / progress bars etc..
Now, this is quite fun, and used to make your dialogs look alot more fun...the
things we can colour are:
Progress bars:
on *:dialog:pbar:init:0: {
dll $mdx SetMircVersion $version
dll $mdx MarkDialog $dname
dll $mdx SetControlMDX $dname <id of pbar> ProgressBar smooth > $ctl
did -a $dname <id> BarColor $rgb(0,0,0)
}
Thats as easy as it is for that.
You can also do Backgrounds for ProgressBar's you jus' add: did -a $dname <id>
BGColor $rgb(0,0,0)
Text:
As you can see the text is purple! now this is really easy!
on *:dialog:text:init:0: {
dll $mdx SetMircVersion $version
dll $mdx MarkDialog $dname
dll $mdx SetColor $dname <id of text> text $rgb(0,0,0)
}
Thats it! Its fairly easy...now for text Background:
See with this, you can combine with the top item as well to create text backgrounds
and text colours, say white on black or black on white.
on *:dialog:text:init:0: {
dll $mdx SetMircVersion $version
dll $mdx MarkDialog $dname
dll $mdx SetColor $dname <id of text> textbg $rgb(0,0,0)
}
There you go! That isn't too hard is it?
Edit Box text and Background:
When changing the colour of editboxes backgrounds and text, you have to apply
both the top two items we learnt, and then another control called background.
Picture:
Code:
on *:dialog:text:init:0: {
dll $mdx SetMircVersion $version
dll $mdx MarkDialog $dname
dll $mdx SetColor $dname <id> textbg $rgb(1,85,92)
dll $mdx SetColor $dname <id> text $rgb(250,45,251)
dll $mdx SetColor $dname <id> background $rgb(1,85,92)
}
There we go..yet another MDX item completed..
Now, for the one I find most annoying, its setting the BG colour of a whole
dialog, lets try.
Dialog BG:
They May not be the prettiest of colours but hey! Heres how we do 'em:
on *:dialog:bg:init:0: {
dll $mdx SetMircVersion $version
dll $mdx MarkDialog $dname
dll $mdx SetDialog $dname bgcolor $rgb(0,0,0)
}
Another new feature! But still easy as anything...
Well that concludes part 1 of the MDX tutorial..
Roger Adams
---------------------------------------------------------------------------------
Contact Info:
Email: Roger
Aim: RgrAdm3
IRC: irc.devcore.co.uk / irc.dal.net / irc.dreamirc.com - channels #vBorg (devcore)
#Scriptaz (DreamIRC) #Meltdownscripters (DAL)
MSN: See email
Website: Scripting Network
Thank you's to:
Triple-H - for the Progress bar code!
DragonZap - for creating MDX
[K]Freak - for teaching me how to make a toolbar in the first place..
And the others I forgot, thank you!
Urls: MDX
DMU - thats
all you need..
---------------------------------------------------------------------------------