name "Broken Installer (BETA)"       ;name of the installer

!include MUI.nsh											 ;includes the Modern User Interface
!include Sections.nsh                  ;includes the radiobutton/mutually-exclusive section selecting

OutFile "Broken.exe"                   ;name of the installer file
SetCompressor lzma                     ;compression method

;!define MUI_BGCOLOR BFCCD6 ; FFFFFF
;!define MUI_INSTFILESPAGE_COLORS "FF0000 000000"

ShowInstDetails show                   ;debugging mode

Var MapRotation ; Which MapRotation does the user want to use?

!define MUI_COMPONENTSPAGE_SMALLDESC
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL

Function RotationChoice
  DetailPrint "$$MapRotation is $MapRotation"
FunctionEnd

SubSection /e "Keybinding Section" SecKeyBindings

  Section "Keep Current KeyBindings" SecKeepKeys
    DetailPrint "User opted to have KeyBindings left alone."
  SectionEnd
  Section /o "Add Stat Bindings" SecStatKeys ; Sets keys to do Stat Net, Stat FPS, etc etc...
    DetailPrint "User chose Stat Bindings, including Stat FPS, Stat net, etc"
  SectionEnd

SubSectionEnd

SubSection /e "Server Map Rotations" SecMapRotations

  Section "Keep Current Map Rotation" SecMaps1
    DetailPrint "Map Rotation left alone."
  SectionEnd

  Section /o "Maps 2" SecMaps2
    Push "Maps2.txt"
    Pop $MapRotation
    call RotationChoice
  SectionEnd

  Section /o "Maps 3" SecMaps3
    Push "Maps3.txt"
    Pop $MapRotation
    call RotationChoice
  SectionEnd

  Section /o "Maps 4" SecMaps4
    Push "Maps4.txt"
    Pop $MapRotation
    call RotationChoice
  SectionEnd

SubSectionEnd

Function .onInit
  StrCpy $1 ${SecKeepKeys} ; Bindings Subsection - SecKeepKeys is selected by default
  StrCpy $2 ${SecMaps1}    ; Rotation Subsection - SecMaps1    is selected by default
FunctionEnd

Function .onSelChange

# only two sections in the subsection so there is no need for this
#  !insertmacro SectionFlagIsSet ${SecKeyBindings} ${SF_SELECTED} 0 KeyBindingsNotSelected
#    !insertmacro UnselectSection ${SecKeepKeys}
#    !insertmacro UnselectSection ${SecStatKeys}
#  KeyBindingsNotSelected:

  !insertmacro SectionFlagIsSet ${SecMapRotations} ${SF_SELECTED} 0 MapRotationsNotSelected
    !insertmacro UnselectSection ${SecMaps1}
    !insertmacro UnselectSection ${SecMaps2}
    !insertmacro UnselectSection ${SecMaps3}
    !insertmacro UnselectSection ${SecMaps4}
  MapRotationsNotSelected:

  !insertmacro StartRadioButtons $1
    !insertmacro RadioButton ${SecKeepKeys}
    !insertmacro RadioButton ${SecStatKeys}
  !insertmacro EndRadioButtons

  !insertmacro StartRadioButtons $2
    !insertmacro RadioButton ${SecMaps1}
    !insertmacro RadioButton ${SecMaps2}
    !insertmacro RadioButton ${SecMaps3}
    !insertmacro RadioButton ${SecMaps4}
  !insertmacro EndRadioButtons

FunctionEnd
