PDA

View Full Version : Lscripters: Is this useful to you? (MsgBox dialog include script)



sami
07-04-2011, 12:21 AM
Just messing around making utilities that help me with my scripts and wanted something better than info() or warning() - something more along the lines of a typical operating system dialog box. So I made MsgBox.ls which codes like this:



// at the beginning of your script
@insert "MsgBox.ls"
...
// Then anywhere in your code
if (MsgBox(int_MsgBoxType, str_MessageText, str_TitlebarText))
{
// user pressed OK on our MsgBox
}

/** Parameters:

int_MsgBoxType = one of these for the icon type: MSG_INFO, MSG_QUES, MSG_WARN, MSG_CRIT, MSG_OK, MSG_CANCEL
str_MessageText = a string which can contain html bold and line break tags like this: "<b>this is bold</b><br>this is on a new line"
str_TitlebarText = a string for the dialog's title caption - though a nil or empty string here will give the default text for the dialog type (i.e. "Information", "Critical" etc)

**/


It handles all the requester stuff, embeds the icons into the script, and auto-sizes the requester based on the message length. Plus it has bold text and manual line breaks via <b></b> and <br> tags. It returns true if the person pressed OK and false if they pressed Cancel.

This is what it can look like:

http://i.imgur.com/TujSX.jpg


Let me know if anyone is interested, I'll just clean it up comment-wise and upload it here. It might save you a bit of trouble and make your dialog boxes stand out a touch from that sea of grey in the interface.

walfridson
07-04-2011, 02:33 AM
cool stuff sami

nickdigital
07-04-2011, 11:09 AM
Nice. I'm interested!

sami
07-04-2011, 09:21 PM
MsgBox v1.0 download

Here it is in case anyone wants it. There are 2 scripts in here. The main script to be inserted (included) into your script (either Layout or Modeler) and a Test script which shows you roughly how the thing works.

Another example of the MsgBox:

http://i.imgur.com/jVZff.jpg


And here's the interface of the test script:

http://i.imgur.com/6MRfI.jpg

TO DO:

Add special symbols and other characters as bold chars - it may crash if you send it foreign symbols beyond ASCII 128 etc.
Add parameter for customizable MAX_WIDTH - currently this is at 80 characters
Fix Auto-wrap to be word-based or syllable-based - currently wrapping is only character-based so you must insert your own line breaks (with the br tag) to get it to look nicest.
Add the ability to have a custom icon (actually this exists currently, but is not overtly exposed since I haven't debugged that part yet)
Add justification styles to text block
Integrate this with my SuperText text drawing utility for requesters. See here (http://www.newtek.com/forums/showthread.php?t=10358&highlight=supertext) for what it does - I'm trying to locate my original source from years ago - I only seem to have my compiled LSC version of it.


Hope it's useful. Enjoy! (and feel free to tell me where my code sucks)

nickdigital
07-04-2011, 09:56 PM
Thanks! :thumbsup:

Tonttu
07-05-2011, 03:51 AM
Gangsta lorem ipsum is my go-to lorem ipsum, too.

evenflcw
07-05-2011, 04:08 AM
Nice work and generous sharing. Thanks!

sami
07-05-2011, 05:45 PM
cool. Hope it's useful. :)