560 likes | 658 Views
Sega 500. Wrapping up t he MUI, And the Power of Shortcuts. You may have noticed…. That there are a few things that my installer does that I didn’t cover last class… Like the sound and the splash screen for example. And so… .
E N D
Sega 500 Wrapping up the MUI, And the Power of Shortcuts.
You may have noticed… • That there are a few things that my installer does that I didn’t cover last class… • Like the sound and the splash screen for example.
And so… • Today, we’re going to round out our NSI scripts by looking at some of the odds and ends that come with the MUI. • And looking at how we can make the “create shortcut” option work in in our favour.
So first off… • Lets just root around the NSIS directory some. • Doing so, you’ll find lots of nsi scripts…But the ones we are really interested in are in the contrib folder.
Take for example • The folder names “splash”. Inside of which you’ll find all sorts of juicy goodness…
What’s this? • Ok, I see the nsi file cool… • But why are there project and workspace files? • ...and the C code for that matter?
Before we look inside… • Compile the NSI file and see what it gives us. • Hey, cool! It throws this up to the screen before the installer runs!
And yeah… • This is how I build the splash screen. • So what’s going on here? • Well, the short answer is that the NSIS comes with several DLL plug-ins which we can use to customise the interface.
Look in the plugins folder. • That’s all the plugins that the NSIS comes with and you can use any one of the. • The best thing is, they all come with samples and a fairly decent readme’s.
And! • As you may have guesses, since we have the dsp and dsw files, they are open source. • Meaning, you can write your own if you like!
But… • I’ll leave that for you to explore on you own… • However, do consider the fact that the installation is the very first exposure that the user has to your game.
Hence… • You should consider this part of the experience of your game and some effort should go into reflecting this. • Just as a for instance:
Red Alert • Was the first company to realize this and really made an interesting install experience with all sorts of game info and catchy music. • Now, I’m not suggesting that you take it to this extreme, just seriously consider it.
Ok, the Splash screen • The example code really covers all we need to know about it. • The only catch is that it has to be done in the .onInit function. • From the example:
Splash screen Function .onInit SetOutPath $TEMP File /oname=spltmp.bmp "my_splash.bmp" splash::show 1000 $TEMP\spltmp Pop $0 ; $0 has '1' if the user closed the splash screen early, ; '0' if everything closed normal, and '-1' if some error occured. Delete $TEMP\spltmp.bmp FunctionEnd
Splash screen • This works like the prebeginplay function in UT. It gets called before the installer actually kicks up. • Then we store a copy of the image in a temp directory for the DLL to load up and use. SetOutPath $TEMP File /oname=spltmp.bmp "my_splash.bmp"
Splash screen • Simply calls the DLL file to display the image (from the temp directory) for X milliseconds. splash::show 1000 $TEMP\spltmp
Splash screen Pop $0 ; $0 has '1' if the user closed the splash screen early, ; '0' if everything closed normal, and '-1' if some error occurred. • And this line pretty much explains itself… • Using this? Copy, Paste, change the parameters for your file and duration. • Really, not much other option here.
Splash screen • Just remember to delete the temp file when your done with it. • However, we can also use this to play a sound file as well…you may have noticed. Delete $TEMP\spltmp.bmp
Splash screen • This really boils down to adding 2 lines of script…no more. • Which sound to play, and delete it when your done… File /oname=spltmp.wav “my_Sound.wav" … <show code> … Delete $TEMP\spltmp.wav
Before we move on… • I want to take a look at the bgImage example as well. • This little app does something similar to the splash screen in that it throws up a full screen back ground image.
bgImage • Now, the functionality is pretty much the same…but there is one thing I’d like to point out, it also plays sounds…lots of sounds…actually the entire windows media directory if you want! • Not worrying about the rest of the file at the moment, here’s how they did it.
bgImage • Essentially they have created a looping condition based on the user feed back from the Message boxes.
bgImage FindFirst $0 $1 $WINDIR\Media\*.wav StrCmp $0 "" skipSound moreSounds: StrCmp $1 "" noMoreSounds BgImage::Sound /NOUNLOAD /WAIT $WINDIR\Media\$1 MessageBox MB_YESNO "Another sound?" IDNO noMoreSounds FindNext $0 $1 Goto moreSounds noMoreSounds: FindClose $0 skipSound:
bgImage • Will grab the first wave file it finds in the it windows media directory. • If it comes back empty, it skips to the end of the function. FindFirst $0 $1 $WINDIR\Media\*.wav StrCmp $0 "" skipSound
bgImage • Otherwise, it does a comparison to the feed back from the user (in register $1) • Then plays the sound through the DLL. StrCmp $1 "" noMoreSounds BgImage::Sound /NOUNLOAD /WAIT $WINDIR\Media\$1
bgImage MessageBox MB_YESNO "Another sound?" IDNO noMoreSounds FindNext $0 $1 Goto moreSounds • If the user hits yes in the message box, we gab another sound based on the last index we had, and loop again.
bgImage noMoreSounds: FindClose $0 • And of course, close the file when we are done. • Now this got me a thinking…
Incrementing Background • “How difficult would it be to have and incrementing background image?“ • E.g. A different one for each section…
Incrementing Background • As it turns out, not hard. But due to the nature of the NSIS script…the logic is a bit…different. • But I really only needed 2 functions and some test sections to pull it off.
Background++ function .onInit strcpy $0 "0" InitPluginsDir ;; load our images File /oname=$PLUGINSDIR\modern-wizard.bmp "${NSISDIR}\Contrib\Icons\modern-wizard.bmp" File /oname=$PLUGINSDIR\checks1.bmp "${NSISDIR}\Contrib\Icons\checks1.bmp" File /oname=$PLUGINSDIR\checksX.bmp "${NSISDIR}\Contrib\Icons\checksX.bmp" ;; show the Init window BgImage::Init /NOUNLOAD /FILLSCREEN $PLUGINSDIR\modern- wizard.bmp functionend
Background++ • All the does is load up a bunch of images to use as our background and throws the first one at the screen. • Next up was the actual function for the backgound…
Background++ function BG Strcmp $0 "1" NEXT1 Strcmp $0 "2" NEXT2 goto end ; 1st pass...init bg NEXT1: BgImage::SetImage /NOUNLOAD /FILLSCREEN $PLUGINSDIR\checks1.bmp goto end NEXT2: BgImage::SetImage /NOUNLOAD /FILLSCREEN $PLUGINSDIR\checksX.bmp end: intop $0 $0 + 1 functionend
Background++ • All that is really happening is that each time the function is called, we check to see which goto case to jump to (my kingdom for switch statement). • At which point we toss the next image up.
Background++ • And lastly, we increment register $0 which we set in the oninit function to 0. • And then finally, in each section, we call the BG function…and lo and behold, it changes with each section.
Background++ • The only thing we have to remember to do is destroy the image class when we are done with it… Section "three" call BG MessageBox MB_OK "3" BgImage::Destroy SectionEnd
And now… • Time to talk about the power of the shortcut as it relates to UT. • We’ve already talked about the creatshortcut command, so why am I showing you this?
Power of the Shortcut • Well, as you no doubt, UT will accept a command line parameter for it’s execution. • This is how we can specify this like the game type and number of players through WOTgreal.
Power of the Shortcut • Remember this? • Well that’s exactly what’s going on. A command line is being pass in when the UT is run.
Power of the Shortcut • So, can you see where I’m going with this? • We can do exactly the same thing with shortcuts, thus customizing UT’s execution.
Power of the Shortcut • Ok, so big whoop! I can specify the gametype and number of bots and what not…yippee. • We’ll actually you can do a whole lot more than that…like tell it which ini file to load!
Power of the Shortcut • So for example you could do something like have UT run and ini file which is specific to your gametype. • And to illustrate the point, if I create a shortcut on my desktop for UT and add F:\UT2003\System\UT2003.exe -Userini=Spam.ini
Power of the Shortcut • It will run UT using my Spam.ini for my player setting. • Go ahead. Copy user.ini and rename to spam…then change the defaultplayer name. • You’ll see it works nicely…
Power of the Shortcut • This works for both the UT2003 and user ini files…consult the UDN for a complete list. http://udn.epicgames.com/pub/Technical/CommandLineOptions/
Power of the Shortcut • Now, this doesn’t quite cover all the tricks… • Remember this fella? • Well, we can specifythis too
Power of the Shortcut • However, it’s a little strange. • The first thing is to make a copy of the UT2003.exe and name it whatever you like. • Then, in the help folder, create an image for the splash screen of the same name but with the addition of “logo”.
Power of the Shortcut • So, we should have: • Now we edit the shortcut to read: Eze.exe in the system folder EzeLogo.bmp in the help folder F:\UT2003\System\Eze.exe -userlogo=EzeLogo.bmp
Power of the Shortcut • And Shazam! • Our custom splash screen!