How-to: Make your own info popups in Studio

columbinecolumbine Posts: 453
edited November 14 in The Commons

MODS: I don't know if this really belongs in the Commons; I don't know where it belongs. Feel free to move it. -c

Because I tend to forget short bits of important information about products unless they're right there in my face along with the other parts of the product, I make a lot of little information icons. These show up in Studio's content tree and can be double-clicked to get a popup dialog with information, just like the pros do!

These instructions should be read and followed carefully, but they are harmless -- the worst that'll happen is you'll make a script that doesn't work, and you'll get an error. However, you are required to:

- Be familiar with your computer's file system (that is, if you see a file path, you know how to get to that location and inspect what's there) and where Daz stores things;

- Know how to use a plain text file editing tool of some kind with confidence (Notepad will work for this, but NOT something like Word that adds extra garbage)

- Have enough sense not to mess with anything that shouldn't be messed with.

Follow these instructions at your own risk.

----------

I'm going to use an actual example I created, because that'll be easier. I needed to make an explanatory popup for Easy Snap Space Habitat so that I wouldn't have to go find a video on YouTube and scan through it every time just to remember the two tiny vital numbers you need to make the snap work right.

Because the info box will live in the same place as the product, first step is to find the product. Note that I have never tried this with items that install via Daz Central/Daz Connect, where the files are stored in a different hierarchy by product ID. I only use DIM or manual install, and I have only ever used this for products installed that way.

For me, Easy Snap Space Habitat lives in
D:\DAZ\LocalLibrary\Environments\Midnight_stories\Space Habitat

Your content structure is probably in a different place; I have an unusual setup. If you don't know how to find the main content tree (this is where you'd find the directories like Data, Runtime, People, Materials, etc), you probably don't want to be trying this.

Anyway, once you've found where you want to put the file, you'll make a text file there with a .dsa extension. The name of this file, minus extension, is what will be displayed as the name of the icon in Studio. So my file
EasySnapSettings.dsa
displays as
EasySnapSettings

Here's the entire contents of that file. All one line. Text only, no special characters, no line breaks.

MessageBox.information(qsTr("Midnight_Stories recommends the following tool snap settings:\nRotate: 45 degrees\nTranslate: 100 cm"), qsTr("Important"), qsTr("&OK"));

You'll notice that there are three places in this line where there's something enclosed in double-quotes. These are the "parameters" and are the only parts you can change. The double-quotes are important -- they're "delimiters," they show the script where your parameter begins and ends. You can't use double-quotes IN the text of these three parameters, or the script will get confused. (You can use apostrophes, though.)

The rest of the line should be kept exactly as you see it here, including capitalization. Don't miss any of the parentheses or the semicolon at the end. It's all important.

The first parameter is the message that will be shown in the dialog. You can't actually type line breaks in the message text, but you can use \n which is a "newline" and the script will know what to do.

My message text is
Midnight_Stories recommends the following tool snap settings:\nRotate: 45 degrees\nTranslate: 100 cm

which will display in the dialog as
Midnight_Stories recommends the following tool snap settings:
Rotate: 45 degrees
Translate: 100 cm

The second parameter is the title of the dialog. Keep this fairly short and don't use the \n newlines. My dialog is titled Important.

The third parameter is what will display on the button you click to close the message box. The ampersand is not displayed; it tells the script that the next character is the hotkey; that is, you can press O to close the message box instead of clicking the button. The button just says OK. Keep this very short and don't use \n here either. (Actually, I don't know why you'd ever want to change this parameter.)

Once you've made your edits and saved your little .dsa file, you may want an icon. You don't have to make one; if you don't, Studio will show the script with the "missing resource" image, AKA the Confused Picture Frame.

If you do care enough to give your new item a real icon (I use an exclamation point in a circle), you'll want to make a 91x91 PNG image of your choice, put it in the same directory, and give it the same name as the file you just made, but with an extension of .png instead of .dsa.

Again:
If your script is
EasySnapSettings.dsa
your icon must be
EasySnapSettings.png
so that Studio will know they go together.

That's it! It takes longer to write up than to do. The hardest part is usually finding where the product lives.

You can do this stuff while you have Studio running and it won't cause problems, but Studio may not automatically see your new script and icon ... you will probably have to restart Studio, to force it to rescan the content tree and get your new goodies to show up.

----------

Notes and nerdy bits:

1. This script calls a function named MessageBox.information() which, amazingly enough, creates an informational message box! I don't know why its parameters need the qsTr("quoted string") wrapper function, and I haven't had time to experiment. Nor can I tell you why it's not qStr(). In the example I first stole this from it was written qsTr and I went with that; one day when I have time to really fool with Studio scripting I will probably learn that was because the original script I stole was done by someone who had no idea either.

2. Similarly, I suspect the script parser IS smart enough to understand line breaks in the script -- say, between parameters (after each comma) to make it more readable -- but I'm not going to experiment right now, and anyway, I'm sure line breaks INSIDE the double-quoted parameters are forbidden. Hence the use of \n.

3. Most scripting languages have a way to "escape" quotation marks (that is, in English, "please literally show these as quotation marks and do not treat them as a string delimiter"), but I don't know what that method is in Studio's scripting language, which is why I say not to use them.

4. I don't know if there is an upper limit on how much message you can cram into one of these popup dialogs. I do know I have a product which has a HUGE info popup that's probably got close to five hundred words in it, so I'm guessing the upper limit is just what your screen can comfortably hold. I wouldn't try to test that theory, though.

5. You can also do a rollover/tooltip image, shown when you hover over the icon. This image can be larger, I think up to 256x256. Some PAs put their special information and instructions right in this image, usually instead of a popup dialog. I prefer the popups; I don't need an image editor to make those when I want one. If you do make a tooltip image it needs to be named .tip.png to match, e.g. in my example EasySnapSettings.tip.png.

Post edited by columbine on

Comments

  • HylasHylas Posts: 4,988

    Thank you! Will give it an try!

  • Thanks for the useful info skit, it is worthwhile doing things like that. Just one additional comment, .tip.png images can be very big. I tend to use 512px square because modern screens are getting to have very high pixels per inch, making images only 256px square a bit small for tired eyes. Regards, Richard.
  • chris-2599934chris-2599934 Posts: 1,810

    columbine said:

    You will probably have to restart Studio, to force it to rescan the content tree and get your new goodies to show up.

    You shouldn't need to do that, just right click on the folder in the Content Library tab and choose "Refresh"

  • GoggerGogger Posts: 2,399

    I appreciate this!  Some items are NOT intuitive to use, and even just a popup reminder to RTFM can save lots of time and frustration.

  • crosswindcrosswind Posts: 6,966
    edited November 15

    You're right: you don't have to use qsTr(). It's pretty OK to use: MessageBox.information("Midnight_Stories recommends the following tool snap settings:\nRotate: 45 degrees\nTranslate: 100 cm", "Important",  "OK")

    To add more line space, replicate n\, e.g. n\n\

    To quote with a quotation mark, use \"

     

    Post edited by crosswind on
  • columbinecolumbine Posts: 453

    crosswind said:

    You're right: you don't have to use qsTr(). It's pretty OK to use: MessageBox.information("Midnight_Stories recommends the following tool snap settings:\nRotate: 45 degrees\nTranslate: 100 cm", "Important",  "OK")

    To add more line space, replicate \n, e.g. \n\n

    To quote with a quotation mark, use \"

    Thank you! I figured someone would come along who had played with the scripting more than I had. One of these days I will actually dive deeply into Studio scripting, but there are only so many hours in the day ...

Sign In or Register to comment.