summaryrefslogtreecommitdiffstats
path: root/sigen.nsi
blob: 7c528923ed3de6b66d3054927da4b2be149b657b (plain)
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
!include "Sections.nsh"

Var AR_SecFlags
Var AR_RegFlags

!macro CheckDependencies SecName
    SectionGetFlags ${${SecName}} $R0
    IntOp $R0 $R0 & ${SF_SELECTED}
    StrCmp $R0 $${SecName}_state +6
    StrCpy $${SecName}_state $R0
    StrCmp $${SecName}_state ${SF_SELECTED} +3
    Call deselect_${SecName}_dependents
    Goto checked_${SecName}
    Call select_${SecName}_dependencies
  checked_${SecName}:
!macroend

!macro UnselectDependent SecName
    SectionGetFlags ${${SecName}} $R0
    IntOp $R1 $R0 & ${SF_SELECTED}
    StrCmp $R1 ${SF_SELECTED} 0 +5
    IntOp $R0 $R0 ^ ${SF_SELECTED}
    SectionSetFlags ${${SecName}} $R0
    StrCpy $${SecName}_state 0
    Call deselect_${SecName}_dependents
!macroend

!macro SelectDependency SecName
    SectionGetFlags ${${SecName}} $R0
    IntOp $R1 $R0 & ${SF_SELECTED}
    StrCmp $R1 ${SF_SELECTED} +5
    IntOp $R0 $R0 | ${SF_SELECTED}
    SectionSetFlags ${${SecName}} $R0
    StrCpy $${SecName}_state ${SF_SELECTED}
    Call select_${SecName}_dependencies
!macroend

!macro DeclareStates SecName
    Var ${SecName}_state
!macroend

!macro InitStates SecName
    SectionGetFlags ${SecName} $R0
    IntOp $R0 $R0 & ${SF_SELECTED}
    StrCpy $${SecName}_state 0
!macroend

!macro InitSection SecName
    ClearErrors
    ReadRegDWORD $AR_RegFlags HKLM "${REG_UNINSTALL}\Components\${SecName}" "Installed"
    IfErrors "default_${SecName}"
    IntOp $AR_RegFlags $AR_RegFlags & 0x0001
    SectionGetFlags ${${SecName}} $AR_SecFlags
    IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE
    IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags
    SectionSetFlags ${${SecName}} $AR_SecFlags
  "default_${SecName}:"
!macroend
 
!macro FinishSection SecName
    SectionGetFlags ${${SecName}} $AR_SecFlags  ;Reading section flags
    IntOp $AR_SecFlags $AR_SecFlags & 0x0001
    IntCmp $AR_SecFlags 1 "leave_${SecName}"
    !insertmacro "Remove_${${SecName}}"
    WriteRegDWORD HKLM "${REG_UNINSTALL}\Components\${SecName}" "Installed" 0
    Goto "exit_${SecName}"
  "leave_${SecName}:"
    WriteRegDWORD HKLM "${REG_UNINSTALL}\Components\${SecName}" "Installed" 1
  "exit_${SecName}:"
!macroend

!macro RemoveSection SecName
    !insertmacro "Remove_${${SecName}}"
!macroend

!define InstFile "sigen.exe"
OutFile "${InstFile}"

!define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\
\Sigma Game Engine"

InstallDir "$PROGRAMFILES\Sigma Game Engine"
Name "Sigma Game Engine"
ComponentText "Check the components you want to add and uncheck the components you want to remove:"
ShowInstDetails show
ShowUnInstDetails show

Section "Required Section"
    SectionIn RO
    
    CreateDirectory $INSTDIR
    WriteUninstaller "$INSTDIR\Uninstall.exe"
    
    WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayName" "Sigma Game Engine"
    WriteRegStr HKLM "${REG_UNINSTALL}" "UninstallString" "$INSTDIR\uninstall.exe"
    WriteRegStr HKLM "${REG_UNINSTALL}" "InstallLocation" "$INSTDIR"
    WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayIcon" "$INSTDIR\sigen.png"
    WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayVersion" "0.0.2"
    WriteRegStr HKLM "${REG_UNINSTALL}" "Publisher" "Nerdy Productions"
    WriteRegStr HKLM "${REG_UNINSTALL}" "InstallSource" "$EXEDIR\"
    WriteRegStr HKLM "${REG_UNINSTALL}" "HelpLink" "http://www.sourceforge.net/projects/sigen"
    WriteRegDWORD HKLM "${REG_UNINSTALL}" "NoModify" 0
    WriteRegDWORD HKLM "${REG_UNINSTALL}" "NoRepair" 0
    WriteRegStr HKLM "${REG_UNINSTALL}" "Comments" "The Sigma Geme Engine is an RPG/Strategy game engine inspired by the original Pokémon™ Games"
    WriteRegStr HKLM "${REG_UNINSTALL}" "ModifyPath" '"$EXEDIR\${InstFile}"'
SectionEnd

Section /o "Common sources" common_src
    DetailPrint "*** Installing common sources..."
    setOutPath "$INSTDIR\src"
    CreateDirectory "$INSTDIR\src"
    file CMakeLists.txt
    file cross-mingw32.cmake
    file cross-mingw32-sigen.sh
    file headers.pri
    file install.pri
    file kde4.pri
    file LICENSE
    file sigen.pro
    file version.pri
SectionEnd
!macro Remove_${common_src}
    DetailPrint "*** Removing common sources..."
    RMDir /R "$INSTDIR\src"
!macroend

Section /o "Sigcore" sigcore_bin
    DetailPrint "*** Installing Sigcore..."
    setOutPath "$INSTDIR\bin"
    CreateDirectory "$INSTDIR\bin"
    file bin/sigcore0.dll
SectionEnd
!macro Remove_${sigcore_bin}
    DetailPrint "*** Removing Sigcore..."
    Delete "$INSTDIR\bin\sigcore0.dll"
!macroend

Section /o "Sigcore sources" sigcore_src
    DetailPrint "*** Installing Sigcore sources..."
    setOutPath "$INSTDIR\src\sigcore"
    CreateDirectory "$INSTDIR\src\sigcore"
    file sigcore/CMakeLists.txt
    file sigcore/sigcore.pro
    file sigcore/*.h
    file sigcore/*.cpp
SectionEnd
!macro Remove_${sigcore_src}
    DetailPrint "*** Removing Sigcore sources..."
    RMDir /R "$INSTDIR\src\sigcore"
!macroend

Section /o "Sigmod" sigmod_bin
    DetailPrint "*** Installing Sigmod..."
    setOutPath "$INSTDIR\bin"
    CreateDirectory "$INSTDIR\bin"
    file bin/sigmod0.dll
SectionEnd
!macro Remove_${sigmod_bin}
    DetailPrint "*** Removing Sigmod..."
    Delete "$INSTDIR\bin\sigmod0.dll"
!macroend

Section /o "Sigmod sources" sigmod_src
    DetailPrint "*** Installing Sigmod sources..."
    setOutPath "$INSTDIR\src\sigmod"
    CreateDirectory "$INSTDIR\src\sigmod"
    file sigmod/CMakeLists.txt
    file sigmod/sigmod.pro
    file sigmod/TODO
    file sigmod/*.h
    file sigmod/*.cpp
SectionEnd
!macro Remove_${sigmod_src}
    DetailPrint "*** Removing Sigmod sources..."
    RMDir /R "$INSTDIR\src\sigmod"
!macroend

Section /o "Sigscript" sigscript_bin
    DetailPrint "*** Installing Sigscript..."
    setOutPath "$INSTDIR\bin"
    CreateDirectory "$INSTDIR\bin"
    file bin/sigscript0.dll
SectionEnd
!macro Remove_${sigscript_bin}
    DetailPrint "*** Removing Sigscript..."
    Delete "$INSTDIR\bin\sigscript0.dll"
!macroend

Section /o "Sigscript sources" sigscript_src
    DetailPrint "*** Installing Sigscript sources..."
    setOutPath "$INSTDIR\src\sigscript"
    CreateDirectory "$INSTDIR\src\sigscript"
    file sigscript/CMakeLists.txt
    file sigscript/sigscript.pro
    file sigscript/TODO
    file sigscript/*.h
    file sigscript/*.cpp
SectionEnd
!macro Remove_${sigscript_src}
    DetailPrint "*** Removing Sigscript sources..."
    RMDir /R "$INSTDIR\src\sigscript"
!macroend

Section /o "Signet" signet_bin
    DetailPrint "*** Installing Signet..."
    setOutPath "$INSTDIR\bin"
    CreateDirectory "$INSTDIR\bin"
    file bin/signet0.dll
SectionEnd
!macro Remove_${signet_bin}
    DetailPrint "*** Removing Signet..."
    Delete "$INSTDIR\bin\signet0.dll"
!macroend

Section /o "Signet sources" signet_src
    DetailPrint "*** Installing Signet sources..."
    setOutPath "$INSTDIR\src\signet"
    CreateDirectory "$INSTDIR\src\signet"
    file signet/CMakeLists.txt
    file signet/signet.pro
    file signet/*.h
    file signet/*.cpp
SectionEnd
!macro Remove_${signet_src}
    DetailPrint "*** Removing Signet sources..."
    RMDir /R "$INSTDIR\src\signet"
!macroend

Section /o "Sigbattle" sigbattle_bin
    DetailPrint "*** Installing Sigbattle..."
    setOutPath "$INSTDIR\bin"
    CreateDirectory "$INSTDIR\bin"
    file bin/sigbattle0.dll
SectionEnd
!macro Remove_${sigbattle_bin}
    DetailPrint "*** Removing Sigbattle..."
    Delete "$INSTDIR\bin\sigbattle0.dll"
!macroend

Section /o "Sigbattle sources" sigbattle_src
    DetailPrint "*** Installing Sigbattle sources..."
    setOutPath "$INSTDIR\src\sigbattle"
    CreateDirectory "$INSTDIR\src\sigbattle"
    file sigbattle/CMakeLists.txt
    file sigbattle/sigbattle.pro
    file sigbattle/TODO
    file sigbattle/*.h
    file sigbattle/*.cpp
SectionEnd
!macro Remove_${sigbattle_src}
    DetailPrint "*** Removing Sigbattle sources..."
    RMDir /R "$INSTDIR\src\sigbattle"
!macroend

Section /o "Sigmodr" sigmodr_bin
    DetailPrint "*** Installing Sigmodr..."
    setOutPath "$INSTDIR\bin"
    CreateDirectory "$INSTDIR\bin"
    file bin/sigmodr.exe
    setOutPath "$INSTDIR\doc"
    CreateDirectory "$INSTDIR\doc"
    file doc/sigmodr.pdf
    setOutPath "$INSTDIR"
    ; TODO: Where to put this? :(
    file sigmodr/sigmodrui.rc
    file sigmod.knsrc
SectionEnd
!macro Remove_${sigmodr_bin}
    DetailPrint "*** Removing Sigmodr..."
    Delete "$INSTDIR\bin\sigmodr.exe"
    Delete "$INSTDIR\doc\sigmodr.pdf"
    Delete "$INSTDIR\sigmodrui.rc"
    Delete "$INSTDIR\sigmod.knsrc"
!macroend

Section /o "Sigmodr Sources" sigmodr_src
    DetailPrint "*** Installing Sigmodr sources..."
    setOutPath "$INSTDIR\src\sigmodr"
    CreateDirectory "$INSTDIR\src\sigmodr"
    file sigmodr/CMakeLists.txt
    file sigmodr/sigmodr.pro
    file sigmodr/sigmodr.tex
    file sigmodr/TODO
    file sigmodr/*.h
    file sigmodr/*.cpp
    file sigmodr/models/*.h
    file sigmodr/models/*.cpp
    file sigmodr/gui/*.ui
    file sigmodr/overlays/*.png
    file sigmodr/overlays/*.qrc
SectionEnd
!macro Remove_${sigmodr_src}
    DetailPrint "*** Removing Sigmodr sources..."
    RMDir /r "$INSTDIR\src\sigmodr"
!macroend

!macro SectionList MacroName
    !insertmacro "${MacroName}" "common_src"
    !insertmacro "${MacroName}" "sigcore_bin"
    !insertmacro "${MacroName}" "sigcore_src"
    !insertmacro "${MacroName}" "sigmod_bin"
    !insertmacro "${MacroName}" "sigmod_src"
    !insertmacro "${MacroName}" "sigscript_bin"
    !insertmacro "${MacroName}" "sigscript_src"
    !insertmacro "${MacroName}" "signet_bin"
    !insertmacro "${MacroName}" "signet_src"
    !insertmacro "${MacroName}" "sigbattle_bin"
    !insertmacro "${MacroName}" "sigbattle_src"
    !insertmacro "${MacroName}" "sigmodr_bin"
    !insertmacro "${MacroName}" "sigmodr_src"
!macroend

!insertmacro SectionList "DeclareStates"

Function .onInit
    !insertmacro SectionList "InitStates"
    !insertmacro SectionList "InitSection"
FunctionEnd

Function deselect_common_src_dependents
    !insertmacro UnselectDependent sigcore_src
FunctionEnd

Function deselect_sigcore_src_dependents
    !insertmacro UnselectDependent sigmod_src
FunctionEnd

Function deselect_sigmod_src_dependents
    !insertmacro UnselectDependent sigmodr_src
    !insertmacro UnselectDependent sigscript_src
FunctionEnd

Function deselect_sigscript_src_dependents
    !insertmacro UnselectDependent sigbattle_src
FunctionEnd

Function deselect_signet_src_dependents
    !insertmacro UnselectDependent sigbattle_src
FunctionEnd

Function deselect_sigbattle_src_dependents
FunctionEnd

Function deselect_sigmodr_src_dependents
FunctionEnd

Function deselect_sigcore_bin_dependents
    !insertmacro UnselectDependent sigmod_bin
FunctionEnd

Function deselect_sigmod_bin_dependents
    !insertmacro UnselectDependent sigmodr_bin
    !insertmacro UnselectDependent sigscript_bin
FunctionEnd

Function deselect_sigscript_bin_dependents
    !insertmacro UnselectDependent sigbattle_bin
FunctionEnd

Function deselect_signet_bin_dependents
    !insertmacro UnselectDependent sigbattle_bin
FunctionEnd

Function deselect_sigbattle_bin_dependents
FunctionEnd

Function deselect_sigmodr_bin_dependents
FunctionEnd

Function select_common_src_dependencies
FunctionEnd

Function select_sigcore_src_dependencies
    !insertmacro SelectDependency common_src
FunctionEnd

Function select_sigmod_src_dependencies
    !insertmacro SelectDependency sigcore_src
FunctionEnd

Function select_sigscript_src_dependencies
    !insertmacro SelectDependency sigmod_src
FunctionEnd

Function select_signet_src_dependencies
FunctionEnd

Function select_sigbattle_src_dependencies
    !insertmacro SelectDependency sigscript_src
    !insertmacro SelectDependency signet_src
FunctionEnd

Function select_sigmodr_src_dependencies
    !insertmacro SelectDependency sigmod_src
FunctionEnd

Function select_sigcore_bin_dependencies
FunctionEnd

Function select_sigmod_bin_dependencies
    !insertmacro SelectDependency sigcore_bin
FunctionEnd

Function select_sigscript_bin_dependencies
    !insertmacro SelectDependency sigmod_bin
FunctionEnd

Function select_signet_bin_dependencies
FunctionEnd

Function select_sigbattle_bin_dependencies
    !insertmacro SelectDependency sigscript_bin
    !insertmacro SelectDependency signet_bin
FunctionEnd

Function select_sigmodr_bin_dependencies
    !insertmacro SelectDependency sigmod_bin
FunctionEnd

Function .onSelChange
    Push $R0
    Push $R1
    !insertmacro SectionList CheckDependencies
    Pop $R1
    Pop $R0
FunctionEnd

Section -FinishComponents
    !insertmacro SectionList "FinishSection"
SectionEnd
 
Section -Post
    ExecShell "open" "$INSTDIR"
SectionEnd

Section Uninstall
    !insertmacro SectionList "RemoveSection"
    
    RMDIR /r $INSTDIR
    DeleteRegKey HKLM "${REG_UNINSTALL}"
SectionEnd