"Launch game when finished" page with NSIS: how?

Discussion in 'Game Development (Technical)' started by stan, Jul 29, 2005.

  1. stan

    Original Member Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    188
    Likes Received:
    0
    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...
     
  2. Tertsi

    Indie Author

    Joined:
    Nov 4, 2004
    Messages:
    513
    Likes Received:
    0
    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. ;)
     
  3. stan

    Original Member Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    188
    Likes Received:
    0
    Thanks a lot! This seems to be exactly what I need, and it's understandable, too ;). I'll try ASAP.
     
  4. GreenGoose

    Original Member

    Joined:
    Jul 6, 2005
    Messages:
    1
    Likes Received:
    0
    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.
     
  5. stan

    Original Member Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    188
    Likes Received:
    0
    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

    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
     
  6. gcarlton

    Original Member

    Joined:
    Jul 17, 2005
    Messages:
    47
    Likes Received:
    0
    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.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer