取消选择互斥文件

时间:2014-04-11 13:35:09

标签: nsis

有两个SectionGroup个,每个包含3个部分。稍后会添加更多内容。 到目前为止,我能够在每组中选择一个且只有一个部分。 我希望能够在之后取消选择,因此选择组中没有任何内容。

代码:

  StrCpy $ButtonGroup1 0
  StrCpy $ButtonGroup2 0

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
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
SectionGroupEnd


; Section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !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 ${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_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 ${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 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

1 个答案:

答案 0 :(得分:0)

Page Components
Page InstFiles

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
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_3}
!insertmacro RadioGroupOrNone_SelChange ${GID_2} ${SID_2_1} ${SID_2_3}
FunctionEnd