aboutsummaryrefslogtreecommitdiff
path: root/Src/installer/winamp/sectionsHelper.nsh
blob: a9c907fa77d0283f7577b5185c6cd53571edbe6e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
!ifndef WINAMP_SECTIONS_HELPER_HEADER
!define WINAMP_SECTIONS_HELPER_HEADER

; use WinampSection/WinampSectionEnd instead of Section/SectionEnd if you want section
; to store invariant name in install.ini
; Example:
; WinampSection "winampSection1" "$(IDS_WINAMPSECTION1_TITLE)" IDX_WINAMPSECTION1
;	....
;	....
; WinampSectionEnd
;
;

!macro WinampSection __sectionName __sectionTitle __sectionIndex
	!ifdef WINAMP_SECTION_ACTIVE_ID | WINAMP_SECTION_ACTIVE_NAME
		!error "Missing WinampSectionEnd"
	!endif
	!define WINAMP_SECTION_ACTIVE_ID		"${__sectionIndex}"
	!define WINAMP_SECTION_ACTIVE_NAME		"${__sectionName}"
	Section "${__sectionTitle}" "${__sectionIndex}"
!macroend

!define WinampSection "!insertmacro 'WinampSection'"

!macro SECTIONHEADER_LINE __line
	!appendfile "${WINAMP_SECTION_HEADER}" "${__line}$\r$\n"
!macroend

!define SECTIONHEADER_LINE	"!insertmacro 'SECTIONHEADER_LINE'"

!macro InitializeGetSectionName
	!ifdef WINAMP_SECTION_HEADER
		!include "${WINAMP_SECTION_HEADER}"
		!delfile "${WINAMP_SECTION_HEADER}"
		SectionGetText $0 $0
		GetSectionName_FunctionEnd:
			Exch $0
		FunctionEnd
	!else
		!define GetSectionName SectionGetText
	!endif
!macroend

!define InitializeGetSectionName	"!insertmacro 'InitializeGetSectionName'"

!macro WinampSectionEnd
	SectionEnd
!ifndef WINAMP_SECTION_ACTIVE_ID | WINAMP_SECTION_ACTIVE_NAME
	!error "Missing WinampSection"
!endif

!ifndef WINAMP_SECTION_HEADER
	!tempfile WINAMP_SECTION_HEADER
	!delfile "${WINAMP_SECTION_HEADER}"

	${SECTIONHEADER_LINE} "!define GetSectionName $\"!insertmacro 'GetSectionName'$\""
	${SECTIONHEADER_LINE} "!macro GetSectionName __sectionIndex __outputVar"
	${SECTIONHEADER_LINE} "$\tPush ${__sectionIndex}"
	${SECTIONHEADER_LINE} "$\tCall GetSectionName"
	${SECTIONHEADER_LINE} "$\tPop ${__outputVar}"
		${SECTIONHEADER_LINE} "!macroend"
	${SECTIONHEADER_LINE} "Function GetSectionName"
	${SECTIONHEADER_LINE} "$\tExch $0"
!endif

	${SECTIONHEADER_LINE} "$\tIntCmp $0	${${WINAMP_SECTION_ACTIVE_ID}} 0 +3 +3"
	${SECTIONHEADER_LINE} "$\t$\tStrCpy $0	${WINAMP_SECTION_ACTIVE_NAME}"
	${SECTIONHEADER_LINE} "$\t$\tGoto GetSectionName_FunctionEnd"

	!undef WINAMP_SECTION_ACTIVE_ID
	!undef WINAMP_SECTION_ACTIVE_NAME
!macroend

!define WinampSectionEnd "!insertmacro 'WinampSectionEnd'"
!endif