sectionsHelper.nsh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. !ifndef WINAMP_SECTIONS_HELPER_HEADER
  2. !define WINAMP_SECTIONS_HELPER_HEADER
  3. ; use WinampSection/WinampSectionEnd instead of Section/SectionEnd if you want section
  4. ; to store invariant name in install.ini
  5. ; Example:
  6. ; WinampSection "winampSection1" "$(IDS_WINAMPSECTION1_TITLE)" IDX_WINAMPSECTION1
  7. ; ....
  8. ; ....
  9. ; WinampSectionEnd
  10. ;
  11. ;
  12. !macro WinampSection __sectionName __sectionTitle __sectionIndex
  13. !ifdef WINAMP_SECTION_ACTIVE_ID | WINAMP_SECTION_ACTIVE_NAME
  14. !error "Missing WinampSectionEnd"
  15. !endif
  16. !define WINAMP_SECTION_ACTIVE_ID "${__sectionIndex}"
  17. !define WINAMP_SECTION_ACTIVE_NAME "${__sectionName}"
  18. Section "${__sectionTitle}" "${__sectionIndex}"
  19. !macroend
  20. !define WinampSection "!insertmacro 'WinampSection'"
  21. !macro SECTIONHEADER_LINE __line
  22. !appendfile "${WINAMP_SECTION_HEADER}" "${__line}$\r$\n"
  23. !macroend
  24. !define SECTIONHEADER_LINE "!insertmacro 'SECTIONHEADER_LINE'"
  25. !macro InitializeGetSectionName
  26. !ifdef WINAMP_SECTION_HEADER
  27. !include "${WINAMP_SECTION_HEADER}"
  28. !delfile "${WINAMP_SECTION_HEADER}"
  29. SectionGetText $0 $0
  30. GetSectionName_FunctionEnd:
  31. Exch $0
  32. FunctionEnd
  33. !else
  34. !define GetSectionName SectionGetText
  35. !endif
  36. !macroend
  37. !define InitializeGetSectionName "!insertmacro 'InitializeGetSectionName'"
  38. !macro WinampSectionEnd
  39. SectionEnd
  40. !ifndef WINAMP_SECTION_ACTIVE_ID | WINAMP_SECTION_ACTIVE_NAME
  41. !error "Missing WinampSection"
  42. !endif
  43. !ifndef WINAMP_SECTION_HEADER
  44. !tempfile WINAMP_SECTION_HEADER
  45. !delfile "${WINAMP_SECTION_HEADER}"
  46. ${SECTIONHEADER_LINE} "!define GetSectionName $\"!insertmacro 'GetSectionName'$\""
  47. ${SECTIONHEADER_LINE} "!macro GetSectionName __sectionIndex __outputVar"
  48. ${SECTIONHEADER_LINE} "$\tPush ${__sectionIndex}"
  49. ${SECTIONHEADER_LINE} "$\tCall GetSectionName"
  50. ${SECTIONHEADER_LINE} "$\tPop ${__outputVar}"
  51. ${SECTIONHEADER_LINE} "!macroend"
  52. ${SECTIONHEADER_LINE} "Function GetSectionName"
  53. ${SECTIONHEADER_LINE} "$\tExch $0"
  54. !endif
  55. ${SECTIONHEADER_LINE} "$\tIntCmp $0 ${${WINAMP_SECTION_ACTIVE_ID}} 0 +3 +3"
  56. ${SECTIONHEADER_LINE} "$\t$\tStrCpy $0 ${WINAMP_SECTION_ACTIVE_NAME}"
  57. ${SECTIONHEADER_LINE} "$\t$\tGoto GetSectionName_FunctionEnd"
  58. !undef WINAMP_SECTION_ACTIVE_ID
  59. !undef WINAMP_SECTION_ACTIVE_NAME
  60. !macroend
  61. !define WinampSectionEnd "!insertmacro 'WinampSectionEnd'"
  62. !endif