-
Notifications
You must be signed in to change notification settings - Fork 5
/
superhudeditor.nsi
296 lines (229 loc) · 8.11 KB
/
superhudeditor.nsi
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
;NSIS Modern User Interface
;Basic Example Script
;Written by Joost Verburg
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
;--------------------------------
;General
;Name and file
Name "SuperHud Editor"
OutFile "superhudeditor-0.3.0-win32.exe"
;Default installation folder
InstallDir "$PROGRAMFILES\superhudeditor"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\superhudeditor" ""
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
; !define MUI_ICON "images\cpma-trans.ico"
;!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install-nsis.ico"
;!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall-nsis.ico"
; MUI Settings / Header
;!define MUI_HEADERIMAGE
;!define MUI_HEADERIMAGE_RIGHT
;!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange-r-nsis.bmp"
;!define MUI_HEADERIMAGE_UNBITMAP "${NSISDIR}\Contrib\Graphics\Header\orange-uninstall-r-nsis.bmp"
; MUI Settings / Wizard
;!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange-nsis.bmp"
;!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange-uninstall-nsis.bmp"
;--------------------------------
;Pages
!define MUI_PAGE_CUSTOMFUNCTION_PRE WelcomePageSetupLinkPre
!define MUI_PAGE_CUSTOMFUNCTION_SHOW WelcomePageSetupLinkShow
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;uninstall.log
!define UninstLog "uninstall.log"
Var UninstLog
;filemissing
LangString UninstLogMissing ${LANG_ENGLISH} "${UninstLog} not found!$\r$\nUninstallation cannot proceed, remove the directory manually."
!macro AddItem Path
FileWrite $UninstLog "${Path}$\r$\n"
!macroend
!define AddItem "!insertmacro AddItem"
; File macro
!macro File FilePath FileName
IfFileExists "$OUTDIR\${FileName}" +2
FileWrite $UninstLog "$OUTDIR\${FileName}$\r$\n"
File "${FilePath}${FileName}"
!macroend
!define File "!insertmacro File"
; FileOname macro
!macro FileOname FilePath FileName TargetFilename
IfFileExists "$OUTDIR\${FileName}" +2
FileWrite $UninstLog "$OUTDIR\${TargetFileName}$\r$\n"
File /oname=${TargetFilename} "${FilePath}${FileName}"
!macroend
!define FileOname "!insertmacro FileOname"
; Copy files macro
!macro CopyFiles SourcePath DestPath
IfFileExists "${DestPath}" +2
FileWrite $UninstLog "${DestPath}$\r$\n"
CopyFiles "${SourcePath}" "${DestPath}"
!macroend
!define CopyFiles "!insertmacro CopyFiles"
; Rename macro
!macro Rename SourcePath DestPath
IfFileExists "${DestPath}" +2
FileWrite $UninstLog "${DestPath}$\r$\n"
Rename "${SourcePath}" "${DestPath}"
!macroend
!define Rename "!insertmacro Rename"
; CreateDirectory macro
!macro CreateDirectory Path
CreateDirectory "${Path}"
FileWrite $UninstLog "${Path}$\r$\n"
!macroend
!define CreateDirectory "!insertmacro CreateDirectory"
; CreateShortcut macro
!macro CreateShortcut FilePath FileTarget
IfFileExists "${FilePath}" +2
FileWrite $UninstLog "${FilePath}$\r$\n"
CreateShortcut "${FilePath}" "${FileTarget}"
!macroend
!define CreateShortcut "!insertmacro CreateShortcut"
; CreateShortcutIcon macro
!macro CreateShortcutIcon FilePath FileTarget Params IconFile IconNo
IfFileExists "${FilePath}" +2
FileWrite $UninstLog "${FilePath}$\r$\n"
CreateShortcut "${FilePath}" "${FileTarget}" "${Params}" "${IconFile}" $IconNo
!macroend
!define CreateShortcutIcon "!insertmacro CreateShortcutIcon"
; SetOutPath macro
!macro SetOutPath Path
SetOutPath "${Path}"
FileWrite $UninstLog "${Path}$\r$\n"
!macroend
!define SetOutPath "!insertmacro SetOutPath"
Section -openlogfile
CreateDirectory "$INSTDIR"
IfFileExists "$INSTDIR\${UninstLog}" +3
FileOpen $UninstLog "$INSTDIR\${UninstLog}" w
Goto +4
SetFileAttributes "$INSTDIR\${UninstLog}" NORMAL
FileOpen $UninstLog "$INSTDIR\${UninstLog}" a
FileSeek $UninstLog 0 END
SectionEnd
;--------------------------------
;Installer Sections
Section "Core files" SecCORE
SectionIn RO
${SetOutPath} "$INSTDIR"
;root
${File} "" "superhudeditor.exe"
${File} "" "webupdater.exe"
${FileOname} "" "ChangeLog" "ChangeLog.txt"
${FileOname} "" "README" "README.txt"
${SetOutPath} "$INSTDIR\data"
${File} "data\" "tips.txt"
${File} "data\" "pak-0.3.0.pke"
${SetOutPath} "$INSTDIR\data\webupdater"
${File} "data\webupdater\" "local.xml"
${File} "data\webupdater\" "webupdatedlg.xrc"
${SetOutPath} "$INSTDIR\Microsoft.VC90.CRT"
${File} "Microsoft.VC90.CRT\" "*.dll"
${File} "Microsoft.VC90.CRT\" "*.manifest"
;Store installation folder
WriteRegStr HKCU "Software\superhudeditor" "" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe"
;Otherwise workingdir in link is wrong!
${SetOutPath} "$INSTDIR"
SectionEnd
Section "Startmenu entry" SecSTARTMENU
${CreateDirectory} "$SMPROGRAMS\SuperHud Editor"
${CreateShortcut} "$SMPROGRAMS\SuperHud Editor\SuperHud Editor.lnk" "$INSTDIR\superhudeditor.exe"
${CreateShortcut} "$SMPROGRAMS\SuperHud Editor\uninstall.lnk" "$INSTDIR\uninstall.exe"
${CreateShortcut} "$SMPROGRAMS\SuperHud Editor\WebUpdater.lnk" "$INSTDIR\webupdater.exe"
SectionEnd
Function WelcomePageSetupLinkPre
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "Numfields" "4" ; increase counter
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 3" "Bottom" "122" ; limit size of the upper label
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Type" "Link"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Text" "http://plrf.org/superhudeditor"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Left" "120"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Right" "315"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Top" "123"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Bottom" "132"
FunctionEnd
Function WelcomePageSetupLinkShow
; Thanks to pengyou
; Fix colors of added link control
; See http://forums.winamp.com/showthread.php?s=&threadid=205674
Push $0
GetDlgItem $0 $MUI_HWND 1203
SetCtlColors $0 "0000FF" "FFFFFF"
; underline font
CreateFont $1 "$(^Font)" "$(^FontSize)" "400" /UNDERLINE
SendMessage $0 ${WM_SETFONT} $1 1
Pop $0
FunctionEnd
;--------------------------------
;Descriptions
;Language strings
LangString DESC_SecCORE ${LANG_ENGLISH} "Application with necessary files. (required)"
LangString DESC_SecSTARTMENU ${LANG_ENGLISH} "Create a startmenu shortcut."
;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecCORE} $(DESC_SecCORE)
!insertmacro MUI_DESCRIPTION_TEXT ${SecSTARTMENU} $(DESC_SecSTARTMENU)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section -closelogfile
FileClose $UninstLog
SetFileAttributes "$INSTDIR\${UninstLog}" READONLY|SYSTEM|HIDDEN
SectionEnd
Section Uninstall
; Can't uninstall if uninstall log is missing!
IfFileExists "$INSTDIR\${UninstLog}" +3
MessageBox MB_OK|MB_ICONSTOP "$(UninstLogMissing)"
Abort
Push $R0
Push $R1
Push $R2
SetFileAttributes "$INSTDIR\${UninstLog}" NORMAL
FileOpen $UninstLog "$INSTDIR\${UninstLog}" r
StrCpy $R1 0
GetLineCount:
ClearErrors
FileRead $UninstLog $R0
IntOp $R1 $R1 + 1
IfErrors 0 GetLineCount
LoopRead:
FileSeek $UninstLog 0 SET
StrCpy $R2 0
FindLine:
FileRead $UninstLog $R0
IntOp $R2 $R2 + 1
StrCmp $R1 $R2 0 FindLine
StrCpy $R0 $R0 -2
IfFileExists "$R0\*.*" 0 +3
RMDir $R0 #is dir
Goto +3
IfFileExists $R0 0 +2
Delete $R0 #is file
IntOp $R1 $R1 - 1
StrCmp $R1 0 LoopDone
Goto LoopRead
LoopDone:
FileClose $UninstLog
Delete "$INSTDIR\${UninstLog}"
RMDir "$INSTDIR"
Pop $R2
Pop $R1
Pop $R0
Delete "$INSTDIR\uninstall.exe"
RmDir "$INSTDIR"
; $LOCALAPPDATA
DeleteRegKey /ifempty HKCU "Software\superhudeditor"
SectionEnd