PDA

View Full Version : "Launch game when finished" page with NSIS: how?


stan
07-29-2005, 08:36 AM
Hey,

I've spent hours searching the web for an explanation on how to add a "Launch game when install is finished" page at the end of my NSIS-installer. The only thing I found was a request for help in a forum, and the explanation seemed particularly complicated for the simple thing that I wanted to do...

I was wondering if any of you knew a simple way to do that. It's probably important to note that I'm not using the "modern UI" thing... (Though I'm not sure what that implies.)

Meanwhile, I'll try again to understand NSIS' doc...

Tertsi
07-29-2005, 08:55 AM
You first create an Optionspage.ini file similar to this one: (There's a GUI editor available for it)

[Settings]
NumFields=6

[Field 1]
Type=Groupbox
Text=Installation options
Left=20
Right=207
Top=33
Bottom=116

[Field 2]
Type=Checkbox
Text=View the up-to-date online manual after installation
Left=25
Right=204
Top=75
Bottom=84
State=0

[Field 3]
Type=Checkbox
Text=View the offline manual after installation
Left=25
Right=190
Top=62
Bottom=72
State=1

[Field 4]
Type=Checkbox
Text=Launch the game after installation
Left=25
Right=190
Top=49
Bottom=59
State=1

[Field 5]
Type=Checkbox
Text=Create startmenu shortcuts
State=1
Left=25
Right=149
Top=88
Bottom=97

[Field 6]
Type=Checkbox
Text=Create a desktop shortcut
State=1
Left=25
Right=149
Top=100
Bottom=110

Then you put these lines in a way you want in the installation script:
(near the top of it)

ReserveFile "Optionspage.ini"
Page license
Page custom SetOptionspage
Page directory
Page instfiles

Then you use these lines at some point:
StrCmp $R3 "1" 0 SKIPGAME
Exec "$INSTDIR\game.exe"
SKIPGAME:

I tried to make this reply to be as comprehensive as possible but I don't have the time to teach you everything atm. so if you have any questions, the manual should help with the rest. ;)

stan
07-29-2005, 09:08 AM
Thanks a lot! This seems to be exactly what I need, and it's understandable, too ;). I'll try ASAP.

GreenGoose
07-29-2005, 12:08 PM
We're using version 2.0 of NSIS, and all we needed to add was a new section to the bottom of our other sections (I've included the previous last section above the one for launching the game):

Section "Desktop Shortcuts"
CreateShortCut "$DESKTOP\Land of Legends ${MAJORVERSION}.lnk" "$INSTDIR\LOL.exe" "" "$INSTDIR\LOL.exe" 0 SW_SHOWNORMAL "" "Land of Legends ${MAJORVERSION}"
SectionEnd

Section "Launch the game after installation"
Exec "$INSTDIR\LOL.exe"
SectionEnd


Hope that helps for people with a similiar NSI setup.

stan
07-29-2005, 04:55 PM
Thanks guys, your answers helped me understand NSIS a bit better and find the solution! Tertsi, it turns out your explanation lacked quite a few things, but it's ok since I found that page which explains (almost) it all: InstallOptions NSIS plugin (http://nsis.sourceforge.net/Docs/InstallOptions/Readme.html)

So, we have to use the InstallOptions plugin. The web page isn't supremely clear on all aspects IMHO, but I managed to make it work anyway ;). There is a bug in the "Call the DLL" section of the doc: a "Pop $R0" is missing before the end of the function.

Also I had to use WriteINIStr to localise the "Text" fields of the GUI before it is opened (since my installer handles English, French and German).

Time to sleep now so I won't explain more, but if anyone has a question or wants to see the relevant parts of my installer script, just ask :).

/me happy

gcarlton
07-29-2005, 05:57 PM
I've found using HM NIS edit is quite handy:
http://hmne.sourceforge.net/

You can make up some options with their wizard and then open up the nsis file and see what the resulting commands were.