Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 19th December 2006, 16:58   #1
davidnewcomb
Junior Member
 
Join Date: Nov 2006
Location: Reading, UK
Posts: 39
Unable to select sections without going to custom install

I have two sections "Install" and "Extract", and 7 sections.
"Extract" has 1 of the sections selected and this simply extracts the payload.
"Install" does a number of tests and depending on external conditions selects 1 to 6 of the sections.
I want to present the user with "Extract" or "Install". The user will not be able to change any of the sections selected.

Unfortunately, I keep running into problems. If I use SectionIn to designate which sections are assigned to an Install type, it switches to a 'Custom' Install option as soon as I change any of them. If I set the components page to use /NOCUSTOM then on loading it sets the Install component type to blank which disappears when I select another option.

I want it to appear with Install and all the required options preselected, so the user can just click next.

The example below is as close as I can get it The type of install is set to blank. When you manually set it to Install it sets the correct options, but this is an extra step which I am trying to get rid of.

!include Sections.nsh
!include MUI.nsh

Name InstTest
OutFile c:\InstText.exe
InstallDir C:\Data\QuentinV3


InstType "Install"
InstType "Extract"
InstType /NOCUSTOM

!insertmacro MUI_PAGE_COMPONENTS

Section "Install Java SDK" sec_install_java
SectionIn ro 1
SectionEnd

Section "Install MySQL database server" sec_install_mysql
SectionIn ro 1
SectionEnd

Section "ISA Manager" sec_install_isa
SectionIn ro 1
SectionEnd

Section "Configure Database" sec_config_db
SectionIn ro 1
SectionEnd

Section "Update Quantel database" sec_config_update
SectionIn ro 1
SectionEnd

Section "Downdate Quantel database" sec_config_downdate
SectionIn ro 1
SectionEnd

Section "File Extract Only" sec_extract_only
SectionIn ro 2
SectionEnd

Function .onInit
!insertmacro ClearSectionInInstType "${sec_install_java}" "${INSTTYPE_1}"
!insertmacro ClearSectionInInstType "${sec_config_update}" "${INSTTYPE_1}"
!insertmacro SetSectionInInstType "${sec_extract_only}" "${INSTTYPE_2}"
FunctionEnd
davidnewcomb is offline   Reply With Quote
Old 19th December 2006, 21:36   #2
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
I guess this is what you're looking for :-)
code:
!define SF_USELECTED 0
!define SF_SELECTED 1
!define SF_RO 16

Name InstTest
OutFile 'InstText.exe'

InstType "Install"
InstType "Extract"
InstType /NOCUSTOM

!include MUI.nsh

!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Section "Install Java SDK" SEC_1
;;;;;;;;;;;;;;
SectionEnd

Section "Install MySQL database server" SEC_2
;;;;;;;;;;;;;;
SectionEnd

Section "ISA Manager" SEC_3
;;;;;;;;;;;;;;;
SectionEnd

Section "Configure Database" SEC_4
;;;;;;;;;;;;;
SectionEnd

Section "Update Quantel database" SEC_5
;;;;;;;;;;;;;;
SectionEnd

Section "Downdate Quantel database" SEC_6
;;;;;;;;;;;;;
SectionEnd

Section "File Extract Only" SEC_7
;;;;;;;;;;;;;;
SectionEnd

Function .onInit
# execute at least this sample script twice by changing the Push below
# respectively to contition1 contition2 and watch the action :-)
Push contition1
Pop $R0
StrCmp $R0 'contition1' contition1 contition2

contition1:
IntOp $0 ${SF_SELECTED} | ${SF_RO}

SectionSetFlags ${SEC_1} $0
SectionSetInstTypes ${SEC_1} 1

SectionSetFlags ${SEC_5} $0
SectionSetInstTypes ${SEC_5} 1

IntOp $0 ${SF_USELECTED} | ${SF_RO}

SectionSetFlags ${SEC_2} $0

SectionSetFlags ${SEC_3} $0

SectionSetFlags ${SEC_4} $0

SectionSetFlags ${SEC_6} $0

IntOp $0 ${SF_USELECTED} | ${SF_RO}

SectionSetFlags ${SEC_7} $0
SectionSetInstTypes ${SEC_7} 2

contition2:
StrCmp $R0 'contition2' 0 exit

IntOp $0 ${SF_SELECTED} | ${SF_RO}

SectionSetFlags ${SEC_1} $0
SectionSetInstTypes ${SEC_1} 1

SectionSetFlags ${SEC_5} $0
SectionSetInstTypes ${SEC_5} 1

SectionSetFlags ${SEC_2} $0
SectionSetInstTypes ${SEC_2} 1

SectionSetFlags ${SEC_3} $0
SectionSetInstTypes ${SEC_3} 1

IntOp $0 ${SF_USELECTED} | ${SF_RO}

SectionSetFlags ${SEC_4} $0

SectionSetFlags ${SEC_6} $0

IntOp $0 ${SF_USELECTED} | ${SF_RO}

SectionSetFlags ${SEC_7} $0
SectionSetInstTypes ${SEC_7} 2

exit:
FunctionEnd


Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 20th December 2006, 13:28   #3
davidnewcomb
Junior Member
 
Join Date: Nov 2006
Location: Reading, UK
Posts: 39
Wow thanks, You have obviously put in a lot of work for this.
It took quite a long time to understand how it works so I will add an explaination for others.

The reason why my orginal showed blank in the selection list was because the selected sections did not match any of the predefined install types.

After a bit of fiddling I found SetSectionInInstType in sections.nsh and wrote 2 macros to help standardise the SectionSet stuff.

code:

!macro AssignInstallSection P_SEC
Push $0
IntOp $0 ${SF_SELECTED} | ${SF_RO}
SectionSetFlags ${P_SEC} $0
Pop $0
!macroend

!macro UnassignInstallSection P_SEC
Push $0
IntOp $0 ${SF_USELECTED} | ${SF_RO}
SectionSetFlags ${P_SEC} $0
Pop $0
!macroend

Function .onInit

!insertmacro SetSectionInInstType ${sec_install_java} 1
!insertmacro AssignInstallSection ${sec_install_java}

!insertmacro ClearSectionInInstType ${sec_install_mysql} 1
!insertmacro UnassignInstallSection ${sec_install_mysql}

!insertmacro ClearSectionInInstType ${sec_install_isa} 1
!insertmacro UnassignInstallSection ${sec_install_isa}

!insertmacro ClearSectionInInstType ${sec_config_db} 1
!insertmacro UnassignInstallSection ${sec_config_db}

!insertmacro SetSectionInInstType ${sec_config_update} 1
!insertmacro AssignInstallSection ${sec_config_update}

!insertmacro ClearSectionInInstType ${sec_config_downdate} 1
!insertmacro UnassignInstallSection ${sec_config_downdate}

!insertmacro SetSectionInInstType ${sec_extract_only} 2


davidnewcomb is offline   Reply With Quote
Old 20th December 2006, 13:54   #4
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Î¥ou're welcome!. Nice job from your side!
Perhaps you may want to take a look at the attached below sample. I think it is a little more pro looking :-)
Attached Files
File Type: nsi test.nsi (3.7 KB, 605 views)

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS

Last edited by Red Wine; 20th December 2006 at 14:52.
Red Wine is offline   Reply With Quote
Old 20th December 2006, 17:11   #5
davidnewcomb
Junior Member
 
Join Date: Nov 2006
Location: Reading, UK
Posts: 39
Maybe 1 for the Wiki!
davidnewcomb is offline   Reply With Quote
Old 20th December 2006, 17:18   #6
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
I've already posted a topic at wiki with the above sample code because here in forum after a few days is not easy to find it by someone who might need it.

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS

Last edited by Red Wine; 20th December 2006 at 18:49.
Red Wine is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump