Steeveeo
23rd May 2008 07:30 UTC
How to make 2 different installs.
Hey all, this is completely frustrating me, as Im still a neophyte in this area, yet I need the feature in my new installer.
What I want to do is release a new version of a mod I made for a game. I have released other versions of the mod before (in Zip files, which were a tiny bit complicated for putting into the game for certain people), and would like to make two options (using nsDialogs); One is a full install of the newest version, and the second will be to patch an existing version up to the latest.
What I cant seem to grasp (although I have no trouble in other types of scripting languages), is how to get the user selection from two radio buttons, then use that get to jump to a section and start installing files from there and only there instead of installing from both sections, then moving from there onto the optional components page.
Here's a little tree of how I want it to work:
User initializes installer->License Page->Directory Page->Full install -OR- Patch up->Components page->End
Problem is, I cant get past the radio buttons, and I cant seem to find an example script which does this.
Here's my current script (installed files excluded):
(Note, this is as-of-yet incomplete, still have to get the Leave script going for the custom page)
!include LogicLib.nsh
!include nsDialogs.nsh
Var Dialog
Var HWND_BUTTON_VI1
Var HWND_BUTTON_VI2
XPStyle on
; Splash
Function .onInit
SetOutPath $TEMP
File /oname=SRVSplash.bmp "SRVSplash.bmp"
advsplash::show 3000 600 400 -1 $TEMP\SRVSplash
Pop $0
Delete $TEMP\SRVSplash.bmp
FunctionEnd
!define PRODUCT_NAME "Steeveeo's Recycler Variant"
!define PRODUCT_VERSION "2.20"
!define PRODUCT_PUBLISHER "SRV Team"
!define PRODUCT_WEB_SITE "http://www.bz2md.com/smf/index.php?board=60.0"
!include "MUI.nsh"
!define MUI_ABORTWARNING
!define MUI_ICON "..\My Documents\My Pictures\sabre.ico"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE "SRV2.20-EULA.txt"
; Components page
;!insertmacro MUI_PAGE_COMPONENTS
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Version Page
Page Custom nsDialogsPage
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\addon\Steeveeo's Recy Variant\README.txt"
!insertmacro MUI_PAGE_FINISH
; Language files
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
Function nsDialogsPage
nsDialogs::Create /NOUNLOAD 1018
!insertmacro MUI_HEADER_TEXT "Installation" "Choose the version to install"
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
Pop $0
${IfThen} $0 == error ${|} Abort ${|}
${NSD_CreateGroupBox} 0u 13u 85% 45% "Select how you want to install SRV v2.20"
Pop $0
;${NSD_CreateLabel} 0 0 100% 12u "Choose how you want to install v2.20"
;Pop $Label
${NSD_CreateRadioButton} 10 50 100% 12u "Full SRV v2.20 Install"
Pop $HWND_BUTTON_VI1
${NSD_CreateRadioButton} 10 70 100% 12u "Update existing SRV v2.06 install to v2.20"
Pop $HWND_BUTTON_VI2
nsDialogs::Show
FunctionEnd
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Install SRV v2.20.exe"
InstallDir "$PROGRAMFILES\Battlezone II\"
ShowInstDetails show
Section "Full Install" FULL
;File Stuff
SectionEnd
Section "2.06 -> 2.20" UPDT
;File Stuff
SectionEnd
Section -Post
SectionEnd
Red Wine
23rd May 2008 16:09 UTC
I'm unable to figure why you need both pages, components and custom, for that kind of install. In my opinion, one should be enough, either components or the custom with the radio buttons.
The scenario that I have in mind is something like this:
-page welcome
-page license
-page components or radios
-page directory
-page instfiles
2 sections, one with full installation files and the other with patch/update files.
When installation begins, check if my application is already installed.
If it is not installed, hide the components/radios page, unselect the patch/update section, and go.
If it is installed, show the components/radios page, get users choice and if users choice is patch/update, unselect section full installation, hide the directory page and go.
Else if users choice is full installation, perform uninstall and continue with a fresh installation as described above.
Steeveeo
23rd May 2008 17:15 UTC
Well, the reason it is needed, is that it is a rather, old, game (Battlezone 2), and does not use RegKeys to run, and also, 99% of the community has 2+ installs (for multiple versions and total conversion mods, its a very devided community, I can delve into why, but that would take up way more time than you'd care for).
Also, the community has an apprehension to uninstallers (for one reason or another. One of my Beta testers yelled at me when I had him test out what I had of the installer so far, saying that improperly made uninstallers can wipe a drive, and was best to leave out that fear by leaving out the uninstaller), and also RegKeys created by installers.
If that had nothing to do with what you're saying, at least I cleared that up :P
Anyway, here's why I need two installs AND a components page:
1A. A user may already have an installed version that needs patching (which involves moving and deleting certain files now and in later versions).
1B. A user wants to install the mod for the first time (in which I can just give them the completed directory instead of molding the existing one into the latest version)
2. The components page is needed because of optional interface files for the game, which a user may or may not want since, although it does optimize the in-game interface to work with the new units introduced into the mod, they may already have an existing interface mod that will cause horrible conflicts if two interface cfg files are used.
Did that make anything clearer or was I just babbling for several paragraphs?
Red Wine
23rd May 2008 18:08 UTC
Don't know, you should check if that did anything clearer with the following example:
!include LogicLib.nsh
!include nsDialogs.nsh
!include "Sections.nsh"
Var Dialog
Var HWND_BUTTON_VI1
Var HWND_BUTTON_VI2
/*
Function .onInit
SetOutPath $TEMP
File /oname=SRVSplash.bmp "SRVSplash.bmp"
advsplash::show 3000 600 400 -1 $TEMP\SRVSplash
Pop $0
Delete $TEMP\SRVSplash.bmp
FunctionEnd
*/
!define PRODUCT_NAME "Steeveeo's Recycler Variant"
!define PRODUCT_VERSION "2.20"
!define PRODUCT_PUBLISHER "SRV Team"
!define PRODUCT_WEB_SITE "http://www.bz2md.com/smf/index.php?board=60.0"
!include "MUI2.nsh"
;!define MUI_ABORTWARNING
;!define MUI_ICON "..\My Documents\My Pictures\sabre.ico"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
;!define MUI_LICENSEPAGE_CHECKBOX
;!insertmacro MUI_PAGE_LICENSE "SRV2.20-EULA.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Version Page
Page Custom nsDialogsPage nsDialogsPageLeave
; Components page
!insertmacro MUI_PAGE_COMPONENTS
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
;!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\addon\Steeveeo's Recy Variant\README.txt"
;!insertmacro MUI_PAGE_FINISH
; Language files
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Install SRV v2.20.exe"
InstallDir "$PROGRAMFILES\Battlezone II\"
ShowInstDetails show
XPStyle on
Section "Full Install" FULL
Detailprint "Installing Section Full Install"
SectionEnd
Section "2.06 -> 2.20" UPDT
Detailprint "Installing Section 2.06 -> 2.20"
SectionEnd
Section /o "Component 1" COMP1
Detailprint "Installing Section Component 1"
SectionEnd
Section /o "Component 2" COMP2
Detailprint "Installing Section Component 2"
SectionEnd
Function nsDialogsPage
!insertmacro MUI_HEADER_TEXT "Installation" "Choose the version to install"
nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog
${IfThen} $Dialog == error ${|} Abort ${|}
${NSD_CreateGroupBox} 0u 13u 85% 45% "Select how you want to install SRV v2.20"
Pop $0
${NSD_CreateRadioButton} 10 50 80% 12u "Full SRV v2.20 Install"
Pop $HWND_BUTTON_VI1
${NSD_CreateRadioButton} 10 70 80% 12u "Update existing SRV v2.06 install to v2.20"
Pop $HWND_BUTTON_VI2
${NSD_AddStyle} $HWND_BUTTON_VI1 ${WS_GROUP}
${NSD_SetState} $HWND_BUTTON_VI1 ${BST_CHECKED}
${NSD_OnBack} DenyBack
nsDialogs::Show
FunctionEnd
Function nsDialogsPageLeave
${NSD_GetState} $HWND_BUTTON_VI1 $R0
${If} $R0 = 1
!insertmacro UnselectSection ${UPDT}
SectionSetText ${UPDT} ""
!insertmacro SelectSection ${FULL}
SectionSetText ${FULL} "Full Install"
!insertmacro SetSectionFlag ${FULL} ${SF_RO}
${Else}
!insertmacro UnselectSection ${FULL}
SectionSetText ${FULL} ""
!insertmacro SelectSection ${UPDT}
SectionSetText ${UPDT} "2.06 -> 2.20"
!insertmacro SetSectionFlag ${UPDT} ${SF_RO}
${EndIf}
FunctionEnd
Function DenyBack
pop $0
Abort
FunctionEnd
Steeveeo
23rd May 2008 23:51 UTC
AhHA! Thank you! That did it!
Now to finish customizing this installer so I can get this out to the public!
Thanks much!
*Adds Red Wine's name to credits list*