How to control Section selections, while using SubSections & InstTypes

From NSIS Wiki
Jump to navigationJump to search
Author: anonymous (talk, contrib)


Description

This script is not completely complete, and has one (maybe major) fault. Apart from that, this script is pretty good since I'm not really any good at programming :p

The 'major' problem, is that clicking on the SubSection will unselect the selected Section, and select all of the other Sections.


e.g. Before clicking on the Hello SubSection...

  • SubSection->Hello
  • Section1-->Unselected
  • Section2-->*Selected
  • Section3-->Unselected
  • Section4-->Unselected

After clicking on the Hello SubSection...

  • SubSection->Hello
  • Section1-->Selected
  • Section2-->*Unselected
  • Section3-->Selected
  • Section4-->Selected

To fix this, the SubSection check box would need to be disabled somehow?


Resuming the code...
This works with 3 SubSections.
Allows for infinite InstTypes.
The first SubSection has 3 Sections.
The second SubSection also has 3 Sections.
The last SubSection has 4 Sections.

First of all you need to make all the sections up...

InstType "Full Compile"
InstType "Full Compile (with old BSP)"
InstType "Full Compile (without RAD)"
InstType "Fast Compile"
InstType "Fast Compile (with fast RAD)"
 
SubSection "1: BSP Map-Compile" SecBSP
 
  Section "BSP Map-Compile Required" SecBSPreq
  SectionIn RO
  SectionEnd
 
  Section "BSP Map-Compile (QBSP3.EXE by Geoffrey DeWan)" SecBSPnew
  SectionIn 1 3 4 5
  SectionEnd
 
  Section "BSP Fix Map-Compile (OLD-QBSP3 by id Software)" SecBSPold
  SectionIn 2
  SectionEnd
 
SubSectionEnd
 
 
SubSection "2: VIS Map-Compile" SecVIS
 
  Section "No VIS Map-Compile" SecVISreq
  SectionEnd
 
  Section "VIS Map-Compile" SecVISfull
  SectionIn 1 2 3
  SectionEnd
 
  Section "VIS Fast Map-Compile" SecVISfast
  SectionIn 4 5
  SectionEnd
 
SubSectionEnd
 
 
SubSection "3: RAD Map-Compile" SecRAD
 
  Section "No RAD Map-Compile" SecRADreq
  SectionEnd
 
  Section "RAD Extra Map-Compile (ArghRad by Tim Wright)" SecRADextra
  SectionIn 1 2
  SectionEnd
 
  Section "RAD Normal (ugly) Map-Compile" SecRADnormal
  SectionEnd
 
  Section "RAD Fast Map-Compile (FQRAD11 by Denis Moeller)" SecRADfast
  SectionIn 5
  SectionEnd
 
SubSectionEnd


And then you add the code...

Function .onInit
 
	Push $0
	Push $5
	Push $R0
 
	StrCpy $1 ${secBSPnew} ; Gotta remember which section we are at now...
	SectionGetFlags ${SecBSPnew} $0
	IntOp $0 $0 | ${SF_SELECTED}
	SectionSetFlags ${SecBSPnew} $0
 
	SectionGetFlags ${SecBSPold} $0
	IntOp $0 $0 & ${SECTION_OFF}
	SectionSetFlags ${SecBSPold} $0
 
	StrCpy $R1 ${secVISfull} ; Gotta remember which section we are at now...
	SectionGetFlags ${SecVIS} $R0
	IntOp $R0 $R0 | ${SF_SELECTED}
	SectionSetFlags ${SecVIS} $R0
 
	SectionGetFlags ${SecVISreq} $R0
	IntOp $R0 $R0 | ${SF_SELECTED}
	SectionSetFlags ${SecVISreq} $R0
 
	SectionGetFlags ${SecVISfull} $R0
	IntOp $R0 $R0 | ${SF_SELECTED}
	SectionSetFlags ${SecVISfull} $R0
 
	SectionGetFlags ${SecVISfast} $R0
	IntOp $R0 $R0 & ${SECTION_OFF}
	SectionSetFlags ${SecVISfast} $R0
 
	StrCpy $8 ${secRADextra} ; Gotta remember which section we are at now...
	SectionGetFlags ${SecRADreq} $5
	IntOp $5 $5 | ${SF_SELECTED}
	SectionSetFlags ${SecRADreq} $5
 
	SectionGetFlags ${SecRADextra} $5
	IntOp $5 $5 | ${SF_SELECTED}
	SectionSetFlags ${SecRADextra} $5
 
	SectionGetFlags ${SecRADnormal} $5
	IntOp $5 $5 & ${SECTION_OFF}
	SectionSetFlags ${SecRADnormal} $5
 
	SectionGetFlags ${SecRADfast} $5
	IntOp $5 $5 & ${SECTION_OFF}
	SectionSetFlags ${SecRADfast} $5
 
	Pop $R0
	Pop $5
	Pop $0
 
FunctionEnd
 
Function .onSelChange
	Push $0
	Push $5
	Push $R0
 
	; Turn off old selected section
	SectionGetFlags $1 $0
	IntOp $0 $0 & ${SECTION_OFF}
	SectionSetFlags $1 $0
 
	SectionGetFlags ${SecBSPnew} $0
	IntOp $0 $0 & ${SF_SELECTED}
	IntCmp $0 ${SF_SELECTED} 0 +2 +2
		StrCpy $1 ${SecBSPnew}
 
	SectionGetFlags ${SecBSPold} $0
	IntOp $0 $0 & ${SF_SELECTED}
	IntCmp $0 ${SF_SELECTED} 0 +2 +2
		StrCpy $1 ${SecBSPold}
 
	StrCmp $1 $1 0 +2 ; selection hasn't changed
		SectionGetFlags $1 $0
		IntOp $0 $R0 | ${SF_SELECTED}
		SectionSetFlags $1 $0
 
 
	; Turn off old selected section
	SectionGetFlags $R1 $R0
	IntOp $R0 $R0 & ${SECTION_OFF}
	SectionSetFlags $R1 $R0
 
	SectionGetFlags ${SecVISreq} $R0
	IntOp $R0 $R0 & ${SF_SELECTED}
	IntCmp $R0 ${SF_SELECTED} 0 +2 +2
		StrCpy $R1 ${SecVISreq}
 
	SectionGetFlags ${SecVISfull} $R0
	IntOp $R0 $R0 & ${SF_SELECTED}
	IntCmp $R0 ${SF_SELECTED} 0 +2 +2
		StrCpy $R1 ${SecVISfull}
 
	SectionGetFlags ${SecVISfast} $R0
	IntOp $R0 $R0 & ${SF_SELECTED}
	IntCmp $R0 ${SF_SELECTED} 0 +2 +2
		StrCpy $R1 ${SecVISfast}
 
	StrCmp $R1 $R1 0 +2 ; selection hasn't changed
		SectionGetFlags $R1 $R0
		IntOp $R0 $R0 | ${SF_SELECTED}
		SectionSetFlags $R1 $R0
 
	; Turn off old selected section
	SectionGetFlags $8 $5
	IntOp $5 $5 & ${SECTION_OFF}
	SectionSetFlags $8 $5
 
 
	SectionGetFlags ${SecRADreq} $5
	IntOp $5 $5 & ${SF_SELECTED}
	IntCmp $5 ${SF_SELECTED} 0 +2 +2
		StrCpy $8 ${SecRADreq}
 
	SectionGetFlags ${SecRADextra} $5
	IntOp $5 $5 & ${SF_SELECTED}
	IntCmp $5 ${SF_SELECTED} 0 +2 +2
		StrCpy $8 ${SecRADextra}
 
	SectionGetFlags ${SecRADnormal} $5
	IntOp $5 $5 & ${SF_SELECTED}
	IntCmp $5 ${SF_SELECTED} 0 +2 +2
		StrCpy $8 ${SecRADnormal}
 
	SectionGetFlags ${SecRADfast} $5
	IntOp $5 $5 & ${SF_SELECTED}
	IntCmp $5 ${SF_SELECTED} 0 +2 +2
		StrCpy $8 ${SecRADfast}
 
	Pop $R0
	Pop $5
	Pop $0
FunctionEnd

-Stu