Skip to content
⌘ NSIS Forum Archive

Final Problem please help

6 posts

TonyDS#

Final Problem please help

This is my components page


And how I would like it to look when its finished, but I have a problem with the script.

What I would like it to do, is when you select one item the other items are unchecked, with the help of pengyou, he managed to achive this using a modified one-section.nsi script, this works fine for the resolutions section, where it alway leave one item selected and you can not uncheck all the boxes.

But for the Cannons and Hangar section, which pengyou also provided the script, does't work as I would like it to do, you see I combined both the scripts he sent me into one, this sort of works but with the cannon and hangar section you can uncheck all the boxes, which I wasn't my intention.

The idea is that you can only select one item from each section, without unchecking all the boxes.

This is the script I'm using which was a combination of two scripts, which is probably wrong

!define RES           $R9
!define CANNON        $R8
!define HANGAR        $R7
!macro HandleSection SECTION
    SectionGetFlags ${SECTION} $0
    IntOp $0 $0 & ${SF_SELECTED}
    IntCmp $0 ${SF_SELECTED} 0 +2 +2
        StrCpy ${RES} ${SECTION}
!macroend
Function .onInit
StrCpy ${RES} ${secR1}
Push $0
StrCpy ${CANNON} ${secCA}
SectionGetFlags ${secCA} $0
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${secCA} $0
SectionGetFlags ${secCB} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${secCB} $0
StrCpy ${HANGAR} ${secHA}
SectionGetFlags ${secHA} $0
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${secHA} $0
SectionGetFlags ${secHB} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${secHB} $0
Pop $0
FunctionEnd
Function .onSelChange
    ;Resolutions
  Push $0
  Push $2
  ; Check if the user have selected all of the sections using the sub-section
    SectionGetFlags ${subsecRes} $0
    IntOp $0 $0 & ${SF_SELECTED}
    StrCmp $0 0 skip
    SectionSetFlags ${secR1} 0
    SectionSetFlags ${secR2} 0
    SectionSetFlags ${secR3} 0
    SectionSetFlags ${secR4} 0
    SectionSetFlags ${secR5} 0
skip:
    ; Turn off old selected section
    !insertmacro UnselectSection ${RES}
    ; Now remember the current selection
    StrCpy $2 ${RES}
  !insertmacro HandleSection ${secR1}
  !insertmacro HandleSection ${secR2}
  !insertmacro HandleSection ${secR3}
  !insertmacro HandleSection ${secR4}
  !insertmacro HandleSection ${secR5}
    StrCmp $2 ${RES} 0 done ; if selection hasn't changed, re-select it
  !insertmacro SelectSection ${RES}
done:
    Pop $2
    Pop $0
    
  Push $0
  StrCmp ${CANNON} ${secCA} check_secCA
  SectionGetFlags ${secCA} $0
  IntOp $0 $0 & ${SF_SELECTED}
  IntCmp $0 ${SF_SELECTED} 0 cannon cannon
  StrCpy ${CANNON} ${secCA}
  SectionGetFlags ${secCB} $0
  IntOp $0 $0 & ${SECTION_OFF}
  SectionSetFlags ${secCB} $0
  Goto  cannon
check_secCA:
  SectionGetFlags ${secCB} $0
  IntOp $0 $0 & ${SF_SELECTED}
  IntCmp $0 ${SF_SELECTED} 0  cannon cannon
  StrCpy ${CANNON} ${secCB}
  SectionGetFlags ${secCA} $0
  IntOp $0 $0 & ${SECTION_OFF}
  SectionSetFlags ${secCA} $0
cannon:
  StrCmp ${HANGAR} ${secHA} check_secHA
  SectionGetFlags ${secHA} $0
  IntOp $0 $0 & ${SF_SELECTED}
  IntCmp $0 ${SF_SELECTED} 0 hangar hangar
  StrCpy ${HANGAR} ${secHA}
  SectionGetFlags ${secHB} $0
  IntOp $0 $0 & ${SECTION_OFF}
  SectionSetFlags ${secHB} $0
  Goto hangar
check_secHA:
  SectionGetFlags ${secHB} $0
  IntOp $0 $0 & ${SF_SELECTED}
  IntCmp $0 ${SF_SELECTED} 0 hangar hangar
  StrCpy ${HANGAR} ${secHB}
  SectionGetFlags ${secHA} $0
  IntOp $0 $0 & ${SECTION_OFF}
  SectionSetFlags ${secHA} $0
hangar:
  Pop $0
FunctionEnd 
If someone could please help me correct this script, so that you can only select one item from each section I would be very grateful, plus I really have to get this finished and working correctly.

Thanks so much

-Tony
deguix#
Please, next time ATTACH, do not include bigger scripts in your messages. Thanks.

[EDIT] Ops! Trying to see again your script [/EDIT]
deguix#
StrCmp ${CANNON} ${secCA} check_secCA

SectionGetFlags ${secCA} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 cannon cannon
StrCpy ${CANNON} ${secCA}
SectionGetFlags ${secCB} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${secCB} $0

Goto cannon

check_secCA:

SectionGetFlags ${secCB} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 cannon cannon
StrCpy ${CANNON} ${secCB}
SectionGetFlags ${secCA} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${secCA} $0

cannon:

StrCmp ${HANGAR} ${secHA} check_secHA

SectionGetFlags ${secHA} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 hangar hangar
StrCpy ${HANGAR} ${secHA}
SectionGetFlags ${secHB} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${secHB} $0

Goto hangar

check_secHA:

SectionGetFlags ${secHB} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 hangar hangar
StrCpy ${HANGAR} ${secHB}
SectionGetFlags ${secHA} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${secHA} $0

hangar:
Replace it by:

  SectionGetFlags ${secCA} $0
  IntOp $0 $0 & ${SF_SELECTED}
  StrCmp $0 ${SF_SELECTED} 0 cannon
    SectionGetFlags ${secCB} $0
    IntOp $0 $0 & ${SECTION_OFF}
    StrCmp $0 ${SECTION_OFF} +2
    SectionSetFlags ${secCB} 0
cannon:
  SectionGetFlags ${secHA} $0
  IntOp $0 $0 & ${SF_SELECTED}
  StrCmp $0 ${SF_SELECTED} 0 hangar
    SectionGetFlags ${secHB} $0
    IntOp $0 $0 & ${SECTION_OFF}
    StrCmp $0 ${SECTION_OFF} +2
    SectionSetFlags ${secHB} $0
hangar: 
Test it and say. (a much simpler code!)
TonyDS#
My apologies for post a long script

And yes it was much simpeler script, but I can still uncheck all the Cannon and Hangar options
TonyDS#
I've done it, I've got it to work

Basic-6 Script

Thanks to those who had the time to help, mainly pengyou.

Cheers Mate 🙂