Hello everyone.
For my latest mod I'm writing an installer with HM NSIS Edit 2.0.3. Now I have a slight problem with the component selection screen. Let me explain:
My mod contains a lot of stuff that's in conflict with each other. To prevent installing these conflicting plugins, I'm using "radio-buttons", which allows only one selected from a certain group of components (if you switch one on, the other one goes automatically off). It works fine for groups with more that two components, however, when I have only a binary option (two components), the button gets stuck. There's no way to select the other option or to turn this option off.
To clarify, I used this code in the Function .onSelChange section. This is the code that causes problems:
Push $2
StrCpy $2 ${SF_SELECTED}
SectionGetFlags ${SEC_ModnProps_LC_MX} $0
IntOp $2 $2 & $0
SectionGetFlags ${SEC_ModnProps_LC_DN} $0
IntOp $2 $2 & $0
StrCmp $2 0 skip2
SectionSetFlags ${SEC_ModnProps_LC_MX} 0
SectionSetFlags ${SEC_ModnProps_LC_DN} 0
skip2:
Pop $2
!insertmacro StartRadioButtons $2
!insertmacro RadioButton ${SEC_ModnProps_LC_MX}
!insertmacro RadioButton ${SEC_ModnProps_LC_DN}
!insertmacro EndRadioButtons
However, the below code works fine:
Push $2
StrCpy $2 ${SF_SELECTED}
SectionGetFlags ${SEC_ModnProps_BE_GREEN} $0
IntOp $2 $2 & $0
SectionGetFlags ${SEC_ModnProps_BE_GREY} $0
IntOp $2 $2 & $0
SectionGetFlags ${SEC_ModnProps_BE_WHITE} $0
IntOp $2 $2 & $0
StrCmp $2 0 skip1
SectionSetFlags ${SEC_ModnProps_BE_GREEN} 0
SectionSetFlags ${SEC_ModnProps_BE_GREY} 0
SectionSetFlags ${SEC_ModnProps_BE_WHITE} 0
skip1:
Pop $2
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${SEC_ModnProps_BE_GREEN}
!insertmacro RadioButton ${SEC_ModnProps_BE_GREY}
!insertmacro RadioButton ${SEC_ModnProps_BE_WHITE}
!insertmacro EndRadioButtons
Any ideas how to solve this?
Best,
Maarten
OK, problem two. NSIS refuses to compile this code:
!insertmacro StartRadioButtons $10
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_CXL_Cl}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_DE_Fr}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_DE_LH}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_DE_Res_RED}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_DE_Res_YELLOW}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_DE_Res_GREEN}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_DE_Res_BLUE}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_DE_Sol}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_FR_CE}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_FR_VT1}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_FR_VT2}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_GEN_OT1}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_GEN_OT2}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_NFSU_JH}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_NL_BSt}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_SE_Gen}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_SE_Got}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_UK_Park}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_USA_CBD}
!insertmacro RadioButton ${SEC_OVR_OVR_RD_HW_USA_Man}
!insertmacro EndRadioButtons
Apperently, if the initial index number is 10 or higher, it refuses to compile. Each Radio Button cycle requires it's own unique index, and I need about 25 of them. This is quite a big problem, since without this option, I can't make my mod fool-proof...
Best,
Maarten
I wouldn't want to meet NSIS in a dark alley, but I have a few ideas. Sorry if they are way off.
The example "one-section.nsi" might help you, it only allows for one button per section to be selected. It is probably already on your computer, but can also be copy/pasted from here (http://nsis.sourceforge.net/Examples/one-section.nsi)
You can try to edit it a little. For example, putting each section into "SectionGroups" will make each group expandable:
SectionGroup "Group 1" g1
Section "Group 1 - Option 1" g1o1
SectionEnd
Section /o "Group 1 - Option 2" g1o2
SectionEnd
Section /o "Group 1 - Option 3" g1o3
SectionEnd
SectionGroupEnd
I tried to do this with the seasonal flora patch, but I had an issue I couldn't solve. When you click on the name of the group, it really messes up the selection. (Tough to explain, if you try, you'll see).
From what I've read about NSIS, there are 20 predefined variables, $0 - $9 and $R0 - $R9. Since you have more than 20, you'll have to define your own. Check out this link, HERE (http://nsis.sourceforge.net/Docs/Chapter4.html#4.2), for how to do this. Though, it does seem a little vague at that site. I was able to google around and figure out how to do it.
Hope this helps.
Thanks for the help, Lowkee! I'll try the SectionGroup option tomorrow ;)
So how did it go ?
Working on my own:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fi40.photobucket.com%2Falbums%2Fe242%2Fvester_DK%2FVDKTrains%2FVDKInstaller.jpg&hash=62b75f0f99db29f6a8945b4df6c745a8bd93570f)
Using nsDialogs and {NSD_CreateRadioButton}.
Started out with NsDialogs FAQ: How to create two groups of RadioButtons (http://nsis.sourceforge.net/NsDialogs_FAQ#How_to_create_two_groups_of_RadioButtons)
What I am trying to do is something a bit like this:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fi40.photobucket.com%2Falbums%2Fe242%2Fvester_DK%2FVDKTrains%2FInstaller2_PS.jpg&hash=40aa052598c22274a3b2cb9467be0071d1eed08e)
Still need to figur out how to change the color of the text in the header.
Its inspired by the WinAmp installer (http://i40.photobucket.com/albums/e242/vester_DK/VDKTrains/1042.jpg).
Quote from: vester on February 14, 2012, 11:06:33 AM
So how did it go ?
Well, not good. I decided to quit the "failsafe" and just deliver some presets. Anyway, the current problems with the mod are quite bigger and I need to flatten those problems out. Point is that my PC has been broken for the past three and a half weeks, so I could not continue with any of my work...
Just looked at the NsDialogs link. I was shocked with the complexity of the interface! A weird mix of Visual Basic and Assembly Languages with Windows API! Are non-professional developers supposed to know all these? Even many professional developers do not know what a HWND is! A very bad concept/design and as far as I can remember they made it this way "for better performance" (over the "oldie" .INI files) although for today's computers and especially for applications like an installer performance is not an issue at all. Features and easiness/convenience for the developer should be the main objectives.
The installers for the RTMT V3.xx versions were made with the good old .INI-format "forms" and it was much easier. I also modified one of the DLLs, allowing to create drop-down list controls with images. Did you check the texture selection drop-down lists in the RTMT installer? They contain both text and images.
In your case, as you have already started working on this, the easiest way would be to add 16 image controls and assign them images (yes, one by one) rather than do something new. Or make one large image with an alpha mask (and the small images being its opaque parts) - only I'm not sure if this will work in all systems; better test it on different computers with both "Small" and "Large" fonts.
I don't know the NsDialogs thingy, but I guess the colour may be possible to be changed in some "property" or "style" setting, where the control (static text?) is defined or created. If not, and as this system seems to rely a lot on the Windows API, a solution could be to process the WM_CTLCOLOR message (refer to the Microsoft documentation for details), as the colour is not a "window style" or "extended style".
Hope this helps
Well I am a total beginner to this still.
I am no coder at all. Can figure out some of it, still its just an empty shell.
Have the script, 4 ini files (Info, ioA, ioB, ioC) but no dll.
I've been thinking about the Appalachian Terrain installer. With all of it's options it only uses one variable to actually decide what to install. If you want to see the syntax, I can post the actual script, but it goes something like this:
// Initialize a variable
Variable A = 0
// Go through which buttons are checked
If Beach is checked, A = A + 1
If High is checked, A = A + 2
If Snow is checked, A = A + 4
// Actually install things
If A = 0, Install Default
If A = 1, Install Beach
If A = 2, Install High
If A = 3, Install Beach and High
If A = 4, Install Snow
If A = 5, Install Beach and Snow
If A = 6, Install High and Snow
If A = 7, Install Beach and High and Snow
So the next option will add 8 to A, so you can have many things happen.
It is a lot of lines, but might be helpful instead of trying to figure out how to make more than 10 variables.
Edit: I've attached the script. It won't compile because non of the files it needs are there, but useful I think.
I know it's been a while, but I think I've actually got an answer now. The original problem:
Quote from: MandelSoft on January 17, 2012, 03:56:58 AMIt works fine for groups with more that two components, however, when I have only a binary option (two components), the button gets stuck.
A sort of hack, just make a third, but hidden option (via omitting the section name)"
; one-section.nsi
;
; This example demonstrates how to control section selection.
; It allows only one of the sections of a group to be selected.
;--------------------------------
; Section define/macro header file
; See this header file for more info
!include "Sections.nsh"
!include "LogicLib.nsh"
;--------------------------------
Name "One Section"
OutFile "one-section.exe"
RequestExecutionLevel user
;--------------------------------
; Pages
Page components
;--------------------------------
; Sections
Section !Required
SectionIn RO
SectionEnd
SectionGroup "Group 1" g1
Section "Group 1 - Option 1" g1o1
SectionEnd
Section /o "Group 1 - Option 2" g1o2
SectionEnd
Section /o "" g1o3
SectionEnd
SectionGroupEnd
SectionGroup "Group2" g2
Section "Group 2 - Option 1" g2o1
SectionEnd
Section /o "Group 2 - Option 2" g2o2
SectionEnd
Section /o "" g2o3
SectionEnd
SectionGroupEnd
;--------------------------------
; Functions
; $1 stores the status of group 1
; $2 stores the status of group 2
Function .onInit
StrCpy $1 ${g1o1} ; Group 1 - Option 1 is selected by default
StrCpy $2 ${g2o1} ; Group 2 - Option 1 is selected by default
FunctionEnd
Function .onSelChange
${If} ${SectionIsSelected} ${g1}
!insertmacro UnSelectSection ${g1}
${ElseIf} ${SectionIsSelected} ${g2}
!insertmacro UnSelectSection ${g2}
${EndIf}
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${g1o1}
!insertmacro RadioButton ${g1o2}
!insertmacro EndRadioButtons
!insertmacro StartRadioButtons $2
!insertmacro RadioButton ${g2o1}
!insertmacro RadioButton ${g2o2}
!insertmacro EndRadioButtons
FunctionEnd
I'm working on an installer with exclusive options, ie "pick a selection from group one or a section from group two":
; one-section.nsi
;
; This example demonstrates how to control section selection.
; It allows only one of the sections of a group to be selected.
;--------------------------------
; Section define/macro header file
; See this header file for more info
!include "Sections.nsh"
!include "LogicLib.nsh"
;--------------------------------
Name "One Section"
OutFile "one-section.exe"
RequestExecutionLevel user
;--------------------------------
; Pages
Page components
;--------------------------------
; Sections
Section !Required
SectionIn RO
SectionEnd
SectionGroup "Group 1" g1
Section "Group 1 - Option 1" g1o1
SectionEnd
Section /o "Group 1 - Option 2" g1o2
SectionEnd
Section /o "Group 1 - Option 3" g1o3
SectionEnd
SectionGroupEnd
SectionGroup "Group2" g2
Section /o "Group 2 - Option 1" g2o1
SectionEnd
Section /o "Group 2 - Option 2" g2o2
SectionEnd
Section /o "Group 2 - Option 3" g2o3
SectionEnd
SectionGroupEnd
;--------------------------------
; Functions
; $1 stores the status of group 1
; $2 stores the status of group 2
Function .onInit
StrCpy $1 ${g1o1} ; Group 1 - Option 1 is selected by default
FunctionEnd
Function .onSelChange
${If} ${SectionIsSelected} ${g1}
!insertmacro UnSelectSection ${g1}
${ElseIf} ${SectionIsSelected} ${g2}
!insertmacro UnSelectSection ${g2}
${EndIf}
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${g1o1}
!insertmacro RadioButton ${g1o2}
!insertmacro RadioButton ${g1o3}
!insertmacro RadioButton ${g2o1}
!insertmacro RadioButton ${g2o2}
!insertmacro RadioButton ${g2o3}
!insertmacro EndRadioButtons
FunctionEnd
Note that these scripts also remove that bug of when you select the group label, rather than something in the group.
Hope people don't mind me opening up this thread again.
Want to keep it together with other stuff on NSIS installer script.
Been writing a script taking a hard look at the NAM installer script (https://www.dropbox.com/s/mye306zeldblzq6/NAM%20Installer%20Script_Monolith.nsi) and this is what I got so far:
!define PRODUCT_NAME "VDK Train Mods - Vol. 09 Passegner Rail"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "vester_DK"
!define PRODUCT_WEB_SITE "http://sc4devotion.com/forums/index.php?board=110.0"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
SetCompressor /SOLID lzma
;Include UltraModernUI
!include "UMUI.nsh"
!include "Sections.nsh" ;SF_Select sættes til 1 heri.
!include "logiclib.nsh"
; Add splash screen
!define MUI_FINISHPAGE_TITLE_3LINES
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "VDKIcon.ico"
;!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP "images\VDK_UMUI installer_image.bmp"
!define UMUI_LEFTIMAGE_BMP "images\VDK_UMUI installer_image.bmp"
!define MUI_COMPONENTSPAGE_SMALLDESC
BrandingText "VDK Train Mods Vol 09 Installer"
; Language Selection Dialog Settings
;:!define UMUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
;:!define UMUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define UMUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
Var ButtonGroup1
Var ButtonGroup2
; Welcome page
; Components page
!insertmacro MUI_PAGE_COMPONENTS
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_SHOWREADME "$DOCUMENTS\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\readme_vdk_train_mods vol09.htm"
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; MUI end ------
Name "${PRODUCT_NAME}"
;Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "VDK_Train_Mods_Vol_9_Installer.exe"
InstallDir "$DOCUMENTS\SimCity 4\Plugins\VDK Automata BSC"
ShowInstDetails show
;ShowUnInstDetails show
Section "ReadMe files" README
SectionIn RO
SetOutPath "$DOCUMENTS\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09"
SetOverwrite ifnewer
File "readme_vdk_train_mods vol09.htm"
SetOutPath "$DOCUMENTS\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\images"
SetOverwrite ifnewer
File "images\ARR.jpg"
File "images\BN1.jpg"
File "images\BN2.jpg"
File "images\BNSF.jpg"
File "images\CBQB.jpg"
File "images\CBQR.jpg"
File "images\Chessie.jpg"
File "images\CN1.jpg"
File "images\CN2.jpg"
File "images\CNW.jpg"
File "images\CoG.jpg"
File "images\CP1.jpg"
File "images\CSX1.jpg"
File "images\Erie.jpg"
File "images\GN1.jpg"
File "images\GN2.jpg"
File "images\GN2.jpg"
File "images\KCS1.jpg"
File "images\Milw.jpg"
File "images\MP1.jpg"
File "images\MP2.jpg"
File "images\NP1.jpg"
File "images\NP2.jpg"
File "images\NS1.jpg"
File "images\NYC.jpg"
File "images\PRRB.jpg"
File "images\PRRG.jpg"
File "images\PRRR.jpg"
File "images\RL.jpg"
File "images\RockIsland.jpg"
File "images\SF1RS.jpg"
File "images\SF2BS.jpg"
File "images\SF3YS.jpg"
File "images\SF4YB.jpg"
File "images\SOO1.jpg"
File "images\SOO2.jpg"
File "images\SPBNCB.jpg"
File "images\SPBWAzer.jpg"
File "images\SPBWUP.jpg"
File "images\SPDL.jpg"
File "images\SPLarkSSRR.jpg"
File "images\SRR1.jpg"
File "images\UP1.jpg"
File "images\Wabash.jpg"
File "images\WSOR.jpg"
SectionEnd
SectionGroup "Select a freight engine replacement mod" FER00
Section /o "Alaska Railroad, ARR" FER01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Mods\FE Rep\VDK FE Rep EMD E9 ARR.dat"
SectionEnd
Section /o "Green Burlington Norhtern, BN1" FER02
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Mods\FE Rep\VDK FE Rep EMD E9 BN1.dat"
SectionEnd
Section /o "Burlington Northern Exclusive, BN2" FER03
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Mods\FE Rep\VDK FE Rep EMD E9 BN2.dat"
SectionEnd
Section /o "BNSF Railways, BNSF" FER04
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Mods\FE Rep\VDK FE Rep EMD E9 BNSF.dat"
SectionEnd
SectionGroupEnd
SectionGroup "Select a steam engine replacement mod" SER00
Section /o "Alaska Railroad, ARR" SER01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Mods\SE Rep\VDK SE Rep EMD E9 ARR.dat"
SectionEnd
Section /o "Green Burlington Norhtern, BN1" SER02
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Mods\SE Rep\VDK SE Rep EMD E9 BN1.dat"
SectionEnd
Section /o "Burlington Northern Exclusive, BN2" SER03
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Mods\SE Rep\VDK SE Rep EMD E9 BN2.dat"
SectionEnd
Section /o "BNSF Railways, BNSF" SER04
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Mods\SE Rep\VDK SE Rep EMD E9 BNSF.dat"
SectionEnd
SectionGroupEnd
SectionGroup "Select one or more freight engine additional mods" FEA00
Section /o "Alaska Railroad, ARR" FEA01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Mods\FE Add\VDK FE Add EMD E9 ARR.dat"
SectionEnd
Section /o "Green Burlington Norhtern, BN1" FEA02
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Mods\FE Add\VDK FE Add EMD E9 BN1.dat"
SectionEnd
Section /o "Burlington Northern Exclusive, BN2" FEA03
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Mods\FE Add\VDK FE Add EMD E9 BN2.dat"
SectionEnd
Section /o "BNSF Railways, BNSF" FEA04
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Mods\FE Add\VDK FE Add EMD E9 BNSF.dat"
SectionEnd
SectionGroupEnd
SectionGroup "Select to make a copy of all the mods" ALL00
Section /o "Copy all Freight Engine Replacement mods" ALL01
SetOutPath "$DOCUMENTS\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\Freight Engines Rep"
SetOverwrite ifnewer
File "Mods\FE Rep\VDK FE Rep EMD E9 ARR.dat"
File "Mods\FE Rep\VDK FE Rep EMD E9 BN1.dat"
File "Mods\FE Rep\VDK FE Rep EMD E9 BN2.dat"
File "Mods\FE Rep\VDK FE Rep EMD E9 BNSF.dat"
SectionEnd
Section /o "Copy all Steam Engine Replacement mods" ALL02
SetOutPath "$DOCUMENTS\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\Steam Engines Rep"
SetOverwrite ifnewer
File "Mods\SE Rep\VDK SE Rep EMD E9 ARR.dat"
File "Mods\SE Rep\VDK SE Rep EMD E9 BN1.dat"
File "Mods\SE Rep\VDK SE Rep EMD E9 BN2.dat"
File "Mods\SE Rep\VDK SE Rep EMD E9 BNSF.dat"
SectionEnd
Section /o "Copy all Freight Engine Addtional mods" ALL03
SetOutPath "$DOCUMENTS\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\Freight Engines Rep"
SetOverwrite ifnewer
File "Mods\FE Add\VDK FE Add EMD E9 ARR.dat"
File "Mods\FE Add\VDK FE Add EMD E9 BN1.dat"
File "Mods\FE Add\VDK FE Add EMD E9 BN2.dat"
File "Mods\FE Add\VDK FE Add EMD E9 BNSF.dat"
SectionEnd
SectionGroupEnd
; Section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${README} "Installs the ReadMe files."
!insertmacro MUI_DESCRIPTION_TEXT ${ALL00} "Copys all mods to the folder: $\n ..\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\"
!insertmacro MUI_DESCRIPTION_TEXT ${ALL01} "Copys all Freight Engine Replacement mods to the folder: $\n ..\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\"
!insertmacro MUI_DESCRIPTION_TEXT ${ALL02} "Copys all Steam Engine Replacement mods to the folder: $\n ..\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\"
!insertmacro MUI_DESCRIPTION_TEXT ${ALL03} "Copys all Freight Engine Replacement mods to the folder: $\n ..\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\"
!insertmacro MUI_DESCRIPTION_TEXT ${FER00} "Select a Freight Engine replacement mod (FE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${FER01} "Installs Alaska Railroad Freight Engine Replacement mod (ARR FE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${FER02} "Installs Green Burlington Northern Freight Engine Replacement mod (BN1 FE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${FER03} "Installs Burlington Northern Exclusive Freight Engine Replacement mod (BN2 FE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${FER04} "Installs BNSF Railways Freight Engine Replacement mod (BNSF FE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${SER00} "Select a Steam Engine replacement mod (SE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${SER01} "Installs Alaska Railroad Steam Engine Replacement mod (ARR SE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${SER02} "Installs Green Burlington Northern Steam Engine Replacement mod (BN1 SE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${SER03} "Installs Burlington Northern Exclusive Steam Engine Replacement mod (BN2 SE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${SER04} "Installs BNSF Railways Steam Engine Replacement mod (BNSF SE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${FEA00} "Select one or more Freight Engine replacement mods (FE Add)."
!insertmacro MUI_DESCRIPTION_TEXT ${FEA01} "Installs Alaska Railroad Steam Engine Replacement mod (ARR SE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${FEA02} "Installs Green Burlington Northern Steam Engine Replacement mod (BN1 SE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${FEA03} "Installs Burlington Northern Exclusive Steam Engine Replacement mod (BN2 SE Rep)."
!insertmacro MUI_DESCRIPTION_TEXT ${FEA04} "Installs BNSF Railways Steam Engine Replacement mod (BNSF SE Rep)."
!insertmacro MUI_FUNCTION_DESCRIPTION_END
; Code for mutually exclusive files.
Function .onInit
StrCpy $ButtonGroup1 0
StrCpy $ButtonGroup2 0
; StrCpy $1 ${FER01} ; Option 1 is default
FunctionEnd
Function .onSelChange
Push $2
StrCpy $2 ${SF_SELECTED}
SectionGetFlags ${FER01} $0
IntOp $2 $2 & $0
SectionGetFlags ${FER02} $0
IntOp $2 $2 & $0
SectionGetFlags ${FER03} $0
IntOp $2 $2 & $0
SectionGetFlags ${FER04} $0
IntOp $2 $2 & $0
StrCmp $2 0 skip1
SectionSetFlags ${FER01} 0
SectionSetFlags ${FER02} 0
SectionSetFlags ${FER03} 0
SectionSetFlags ${FER04} 0
skip1:
Pop $2
!insertmacro StartRadioButtons $ButtonGroup1
!insertmacro RadioButton ${FER01}
!insertmacro RadioButton ${FER02}
!insertmacro RadioButton ${FER03}
!insertmacro RadioButton ${FER04}
!insertmacro EndRadioButtons
Push $2
StrCpy $2 ${SF_SELECTED}
SectionGetFlags ${SER01} $0
IntOp $2 $2 & $0
SectionGetFlags ${SER02} $0
IntOp $2 $2 & $0
SectionGetFlags ${SER03} $0
IntOp $2 $2 & $0
SectionGetFlags ${SER04} $0
IntOp $2 $2 & $0
StrCmp $2 0 skip2
SectionSetFlags ${SER01} 0
SectionSetFlags ${SER02} 0
SectionSetFlags ${SER03} 0
SectionSetFlags ${SER04} 0
skip2:
Pop $2
!insertmacro StartRadioButtons $ButtonGroup1
!insertmacro RadioButton ${SER01}
!insertmacro RadioButton ${SER02}
!insertmacro RadioButton ${SER03}
!insertmacro RadioButton ${SER04}
!insertmacro EndRadioButtons
FunctionEnd
Lets zoom in on the section
Function .onSelChange
Push $2
StrCpy $2 ${SF_SELECTED}
SectionGetFlags ${FER01} $0
IntOp $2 $2 & $0
SectionGetFlags ${FER02} $0
IntOp $2 $2 & $0
SectionGetFlags ${FER03} $0
IntOp $2 $2 & $0
SectionGetFlags ${FER04} $0
IntOp $2 $2 & $0
StrCmp $2 0 skip1
SectionSetFlags ${FER01} 0
SectionSetFlags ${FER02} 0
SectionSetFlags ${FER03} 0
SectionSetFlags ${FER04} 0
skip1:
Pop $2
!insertmacro StartRadioButtons $ButtonGroup1
!insertmacro RadioButton ${FER01}
!insertmacro RadioButton ${FER02}
!insertmacro RadioButton ${FER03}
!insertmacro RadioButton ${FER04}
!insertmacro EndRadioButtons
Push $2
StrCpy $2 ${SF_SELECTED}
SectionGetFlags ${SER01} $0
IntOp $2 $2 & $0
SectionGetFlags ${SER02} $0
IntOp $2 $2 & $0
SectionGetFlags ${SER03} $0
IntOp $2 $2 & $0
SectionGetFlags ${SER04} $0
IntOp $2 $2 & $0
StrCmp $2 0 skip2
SectionSetFlags ${SER01} 0
SectionSetFlags ${SER02} 0
SectionSetFlags ${SER03} 0
SectionSetFlags ${SER04} 0
skip2:
Pop $2
!insertmacro StartRadioButtons $ButtonGroup1
!insertmacro RadioButton ${SER01}
!insertmacro RadioButton ${SER02}
!insertmacro RadioButton ${SER03}
!insertmacro RadioButton ${SER04}
!insertmacro EndRadioButtons
FunctionEnd
This gives me 4 sections:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FRpeQsxJ.jpg&hash=1a5712be86a6341bb08437cac42923cc0b95b76c)
So would like it to be able to do is, if you selct one of the Freight/steam replacement mods, you can't unselect it again.
I have tried the method that is use the NAM installer script.
That would look like this:
Function .onSelChange
${If} ${SectionIsSelected} ${FER1}
${OrIf} ${SectionIsSelected} ${FER2}
${OrIf} ${SectionIsSelected} ${FER3}
${OrIf} ${SectionIsSelected} ${FER4}
Push $2
StrCpy $2 ${SF_SELECTED}
SectionGetFlags ${FER1} $0
IntOp $2 $2 & $0
SectionGetFlags ${FER2} $0
IntOp $2 $2 & $0
SectionGetFlags ${FER3} $0
IntOp $2 $2 & $0
SectionGetFlags ${FER4} $0
IntOp $2 $2 & $0
StrCmp $2 0 skip1
SectionSetFlags ${FER1} 0
SectionSetFlags ${FER2} 0
SectionSetFlags ${FER3} 0
SectionSetFlags ${FER4} 0
skip1:
Pop $2
!insertmacro StartRadioButtons $ButtonGroup1
!insertmacro RadioButton ${FER1}
!insertmacro RadioButton ${FER2}
!insertmacro RadioButton ${FER3}
!insertmacro RadioButton ${FER4}
!insertmacro EndRadioButtons
${EndIf}
This I took from the script where its says ButtonGroup10
"This option replaces the standard arrow textures with ones similar "....:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FDJ2puLP.jpg&hash=0045f0ca3e44367ebff61353a808d48334e1ab37)
So a bit short of answers here, I went and posted by problem on stackoverflow and got a reply with some code:
Page Components
Page InstFiles
OutFile "test.exe"
SectionGroup /e "G1" GID_1
Section /o "1.1" SID_1_1
SectionEnd
Section /o "1.2" SID_1_2
SectionEnd
Section /o "1.3" SID_1_3
SectionEnd
Section /o "1.4" SID_1_4
SectionEnd
SectionGroupEnd
SectionGroup /e "G2" GID_2
Section /o "2.1" SID_2_1
SectionEnd
Section /o "2.2" SID_2_2
SectionEnd
Section /o "2.3" SID_2_3
SectionEnd
SectionGroupEnd
!include Sections.nsh
!include LogicLib.nsh
!macro RadioGroupOrNone_SelChange gid sidf sidl
Push $0
Push $1
Push $2
Push $3
Var /GLOBAL RGON_${gid}_SID
StrCpy $2 0
${For} $1 ${sidf} ${sidl}
${If} ${SectionIsSelected} $1
IntOp $2 $2 + 1
${EndIf}
${Next}
${IfThen} $2 U< 2 ${|} StrCpy $RGON_${gid}_SID 0 ${|}
StrCpy $2 0
StrCpy $3 0
${For} $1 ${sidf} ${sidl}
${If} ${SectionIsSelected} $1
${If} $RGON_${gid}_SID = $1
SectionGetFlags $1 $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags $1 $0
${Else}
IntOp $2 $2 + 1
StrCpy $3 $1
${EndIf}
${EndIf}
${Next}
StrCpy $RGON_${gid}_SID $3
${If} $2 U> 1
SectionGetFlags ${gid} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${gid} $0
StrCpy $RGON_${gid}_SID 0
${EndIf}
Pop $3
Pop $2
Pop $1
Pop $0
!macroend
Function .onSelChange
!insertmacro RadioGroupOrNone_SelChange ${GID_1} ${SID_1_1} ${SID_1_4}
!insertmacro RadioGroupOrNone_SelChange ${GID_2} ${SID_2_1} ${SID_2_3}
FunctionEnd
So if you add a section to a sectiongroup, make sure to the variables in the "call line" of the macro RadioGroupOrNone_SelChange to match up with the name of the last section in that group (that being in this case SID_1_4 and SIG_2_3 ).
Hope someone else can use this code for something as well.