-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate-installer.nsi
executable file
·143 lines (133 loc) · 5.07 KB
/
create-installer.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
Name "Tibia maps"
OutFile "Tibia-11-maps-installer.exe"
BrandingText " "
Icon "icon.ico"
Caption "Tibia 11 maps installer by TibiaMaps.io"
VIProductVersion "1.2.0.0"
VIAddVersionKey CompanyName "TibiaMaps.io"
VIAddVersionKey FileDescription "Tibia maps installer for Tibia 11, powered by the TibiaMaps.io maps."
VIAddVersionKey FileVersion "1.2.0"
VIAddVersionKey LegalCopyright TibiaMaps.io
VIAddVersionKey OriginalFilename "Tibia 11 maps installer.exe"
VIAddVersionKey ProductName "Tibia 11 maps installer"
!include "Sections.nsh" ; Include the plugin for checkboxes.
!include "zipdll.nsh" ; Include the ZIP plugin.
Page components
Page instfiles
; Set up the selection screen.
Section "Tibia maps with markers" P1
FindProcDLL::FindProc "client.exe" ; Show an error if Tibia is running.
IntCmp $R0 1 0 notRunning
MessageBox MB_OK|MB_ICONEXCLAMATION "Tibia is running. Please close it first." /SD IDOK
goto end
notRunning: ; If Tibia isn’t running, start downloading the map files.
inetc::get "https://tibiamaps.io/downloads/minimap-with-markers" "$pluginsdir\minimap.zip" /END
Pop $R0 ; Get the return value.
StrCmp $R0 "OK" +3
MessageBox MB_OK "Download failed; try again later."
Quit
Pop $0
end:
SectionEnd
Section /o "Tibia maps without markers" P2
IntCmp $R0 1 0 notRunning
MessageBox MB_OK|MB_ICONEXCLAMATION "Tibia is running. Please close it first." /SD IDOK
goto end
notRunning: ; If Tibia isn’t running, start downloading the map files.
inetc::get "https://tibiamaps.io/downloads/minimap-without-markers" "$pluginsdir\minimap.zip" /END
Pop $R0 ; Get the return value.
StrCmp $R0 "OK" +3
MessageBox MB_OK "Download failed; try again later."
Quit
Pop $0
end:
SectionEnd
Section /o "Tibia maps with grid overlay and markers" P3
IntCmp $R0 1 0 notRunning
MessageBox MB_OK|MB_ICONEXCLAMATION "Tibia is running. Please close it first." /SD IDOK
goto end
notRunning: ; If Tibia isn’t running, start downloading the map files.
inetc::get "https://tibiamaps.io/downloads/minimap-with-grid-overlay-and-markers" "$pluginsdir\minimap.zip" /END
Pop $R0 ; Get the return value.
StrCmp $R0 "OK" +3
MessageBox MB_OK "Download failed; try again later."
Quit
Pop $0
end:
SectionEnd
Section /o "Tibia maps with grid overlay and PoI markers" P4
IntCmp $R0 1 0 notRunning
MessageBox MB_OK|MB_ICONEXCLAMATION "Tibia is running. Please close it first." /SD IDOK
goto end
notRunning: ; If Tibia isn’t running, start downloading the map files.
inetc::get "https://tibiamaps.io/downloads/minimap-with-grid-overlay-and-poi-markers" "$pluginsdir\minimap.zip" /END
Pop $R0 ; Get the return value.
StrCmp $R0 "OK" +3
MessageBox MB_OK "Download failed; try again later."
Quit
Pop $0
end:
SectionEnd
Section /o "Tibia maps with grid overlay without markers" P5
IntCmp $R0 1 0 notRunning
MessageBox MB_OK|MB_ICONEXCLAMATION "Tibia is running. Please close it first." /SD IDOK
goto end
notRunning: ; If Tibia isn’t running, start downloading the map files.
inetc::get "https://tibiamaps.io/downloads/minimap-with-grid-overlay-without-markers" "$pluginsdir\minimap.zip" /END
Pop $R0 ; Get the return value.
StrCmp $R0 "OK" +3
MessageBox MB_OK "Download failed; try again later."
Quit
Pop $0
end:
SectionEnd
; Handle the installation.
Section
IntCmp $R0 1 0 notRunning
Quit
notRunning:
IfFileExists "$pluginsdir\minimap.zip" fileExist
Quit
fileExist:
IfFileExists "$LOCALAPPDATA\Tibia\packages\Tibia\minimap\*.*" folderExist
goto folderDontExist
folderExist:
DetailPrint "Removing old map files..."
DetailPrint "Deleting $LOCALAPPDATA\Tibia\packages\Tibia\minimap..."
RMDir /r "$LOCALAPPDATA\Tibia\packages\Tibia\minimap"
folderDontExist:
DetailPrint "Installing new map files..."
!insertmacro ZIPDLL_EXTRACT "$pluginsdir\minimap.zip" "$LOCALAPPDATA\Tibia\packages\Tibia" "<ALL>"
DetailPrint "Cleaning up temporary files..."
Delete "$pluginsdir\minimap.zip"
SectionEnd
; Startup checks and variables.
Function .onInit
Initpluginsdir ; Make sure `$pluginsdir` exists.
StrCpy $1 ${P1} ; The default.
; Size (kB) of uncompressed ZIP with marker data.
; unzip -l minimap-with-markers.zip | tail -n 1 | bytes_to_kilobytes
SectionSetSize ${P1} 6224
; Size (KB) of uncompressed ZIP without marker data.
; unzip -l minimap-without-markers.zip | tail -n 1 | bytes_to_kilobytes
SectionSetSize ${P2} 6085
; Size (KB) of uncompressed ZIP with grid overlay and marker data.
; unzip -l minimap-with-grid-overlay-and-markers.zip | tail -n 1 | bytes_to_kilobytes
SectionSetSize ${P3} 6284
; Size (KB) of uncompressed ZIP with grid overlay with PoI marker data.
; unzip -l minimap-with-grid-overlay-and-poi-markers.zip | tail -n 1 | bytes_to_kilobytes
SectionSetSize ${P4} 6188
; Size (KB) of uncompressed ZIP with grid overlay without marker data.
; unzip -l minimap-with-grid-overlay-without-markers.zip | tail -n 1 | bytes_to_kilobytes
SectionSetSize ${P5} 6144
FunctionEnd
; Ensure only a single checkbox can be checked at any time.
Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${P1}
!insertmacro RadioButton ${P2}
!insertmacro RadioButton ${P3}
!insertmacro RadioButton ${P4}
!insertmacro RadioButton ${P5}
!insertmacro EndRadioButtons
FunctionEnd