; opplus_41_shiplist_swapper.nsi
;
;--------------------------------
; The name of the installer
Name "OP+ 4.1 ShipList Swapper"
; The File to write
OutFile "opplus_41_shiplist_swapper.exe"
; The default installation directory
InstallDir "$PROGRAMFileS\Taldren Software Inc.\Starfleet Command Orion Pirates"
; detect SFC:OP path from uninstall string if available
InstallDirRegKey HKLM \
"SOFTWARE\Taldren\Starfleet Command Orion Pirates" \
"Directory"
; The text to prompt the user to enter a directory
DirText "Please select your SFC:OP path below:"
; Silly Vista and Windows 7
RequestExecutionLevel admin
;--------------------------------
;Page custom splashImage "" ": Splash Image"
;Page license
Page components
Page instFiles
;--------------------------------
!ifndef NOINSTTYPES ; only if not defined
InstType "Switch to OP+ 4.1"
InstType "Switch to OP+ 4.0"
InstType "Switch to OP 2.5.5.2 stock shiplist files"
# InstType /NOCUSTOM
!endif
; don't show HD space data
SpaceTexts none
; automatically close the installer when done.
; AutoCloseWindow true
; hide the "show details" box
; ShowInstDetails nevershow
;SetCompressor /final /solid lzma
;SetCompressorDictSize 20
;SetDateSave off
SetCompressor zlib
;--------------------------------
Section "Switch to OP+ 4.1" opplus41
SectionIn 1
; Installs to all users
SetShellVarContext all
; Step 0 -- if already installed, recommend to uninstall previous opplus, and abort
; IfFileExists File_to_check_for jump_if_present [jump_otherwise]
IfFileExists "$INSTDIR\opplus41\shiplist.txt" FileFound noFilefound
FileFound:
; Step 1- Fix file attributes
SetFileAttributes "$INSTDIR\MetaAssets\shiplist.txt" NORMAL
SetFileAttributes "$INSTDIR\MetaAssets\ftrlist.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\Specs\shiplist.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\Specs\ftrlist.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\strings\strings.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\strings\shipnames.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\models\model.siz" NORMAL
; Step 2- Copy over files from OP+ 4.1
; Set output path to the installation directory.
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\shiplist.txt" "$INSTDIR\Assets\Specs"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\ftrlist.txt" "$INSTDIR\Assets\Specs"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\shiplist.txt" "$INSTDIR\MetaAssets"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\ftrlist.txt" "$INSTDIR\MetaAssets"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\strings.txt" "$INSTDIR\Assets\strings"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\shipnames.txt" "$INSTDIR\Assets\strings"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\model.siz" "$INSTDIR\Assets\models"
Goto end
noFileFound:
MessageBox MB_OK "OP+ 4.1 shiplist.txt file is MISSING. Reinstall??"
end:
SectionEnd
;--------------------------------
;--------------------------------
Section "Switch to OP+ 4.0" opplus40
SectionIn 2
; Installs to all users
SetShellVarContext all
; Step 0 -- if already installed, recommend to uninstall previous opplus, and abort
; IfFileExists File_to_check_for jump_if_present [jump_otherwise]
IfFileExists "$INSTDIR\opplus\shiplist.txt" FileFound noFilefound
FileFound:
; Step 1- Fix file attributes
SetFileAttributes "$INSTDIR\MetaAssets\shiplist.txt" NORMAL
SetFileAttributes "$INSTDIR\MetaAssets\ftrlist.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\Specs\shiplist.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\Specs\ftrlist.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\strings\strings.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\strings\shipnames.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\models\model.siz" NORMAL
; Step 2- Copy over files from OP+ 4.0
; Set output path to the installation directory.
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus\shiplist.txt" "$INSTDIR\Assets\Specs"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus\ftrlist.txt" "$INSTDIR\Assets\Specs"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus\shiplist.txt" "$INSTDIR\MetaAssets"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus\ftrlist.txt" "$INSTDIR\MetaAssets"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus\strings.txt" "$INSTDIR\Assets\strings"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus\shipnames.txt" "$INSTDIR\Assets\strings"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus\model.siz" "$INSTDIR\Assets\models"
Goto end
noFileFound:
MessageBox MB_OK "OP+ 4.0 shiplist.txt file is MISSING. Reinstall??"
end:
SectionEnd
;--------------------------------
;--------------------------------
Section "Switch to OP 2.5.5.2 stock shiplist files" opstock2552
SectionIn 3
; Installs to all users
SetShellVarContext all
; Step 0 -- if already installed, recommend to uninstall previous opplus, and abort
; IfFileExists File_to_check_for jump_if_present [jump_otherwise]
IfFileExists "$INSTDIR\opplus41\original_files_2552\shiplist.txt" FileFound noFilefound
FileFound:
; Step 1- Fix file attributes
SetFileAttributes "$INSTDIR\MetaAssets\shiplist.txt" NORMAL
SetFileAttributes "$INSTDIR\MetaAssets\ftrlist.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\Specs\shiplist.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\Specs\ftrlist.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\strings\strings.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\strings\shipnames.txt" NORMAL
SetFileAttributes "$INSTDIR\Assets\models\model.siz" NORMAL
; Step 2- Copy over files from OP+ 4.0
; Set output path to the installation directory.
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\original_files_2552\shiplist.txt" "$INSTDIR\Assets\Specs"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\original_files_2552\ftrlist.txt" "$INSTDIR\Assets\Specs"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\original_files_2552\shiplist.txt" "$INSTDIR\MetaAssets"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\original_files_2552\ftrlist.txt" "$INSTDIR\MetaAssets"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\original_files_2552\strings.txt" "$INSTDIR\Assets\strings"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\original_files_2552\shipnames.txt" "$INSTDIR\Assets\strings"
CopyFiles /SILENT /FILESONLY "$INSTDIR\opplus41\original_files_2552\model.siz" "$INSTDIR\Assets\models"
Goto end
noFileFound:
MessageBox MB_OK "Cannot find 2.5.5.2 shiplist.txt file from OP+ 4.1. Reinstall OP+ 4.1?"
end:
SectionEnd
;--------------------------------
# defines for newer versions
!include Sections.nsh
# SECTION_OFF is defined in Sections.nsh as 0xFFFFFFFE
!define SECTION_ON ${SF_SELECTED} # 0x1
# defines for 2.0b0 and below
#!define SECTION_ON 0x80000000
#!define SECTION_OFF 0x7FFFFFFF
Function .onInit
InitPluginsDir
; call userInfo plugin to get user info. The plugin puts the result in the stack
userInfo::getAccountType
; pop the result from the stack into $0
pop $0
; compare the result with the string "Admin" to see if the user is admin.
strCmp $0 "Admin" user_is_admin abort_user_is_not_admin
abort_user_is_not_admin:
MessageBox MB_OK "You must be an Administrator to install this software."
Abort
user_is_admin:
; --------------- and now we set up section state
Push $0
StrCpy $1 ${opplus41} ; Gotta remember which section we are at now...
SectionGetFlags ${opplus41} $0
IntOp $0 $0 | ${SECTION_ON}
SectionSetFlags ${opplus41} $0
SectionGetFlags ${opplus40} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${opplus40} $0
SectionGetFlags ${opstock2552} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${opstock2552} $0
Pop $0
FunctionEnd
Function .onSelChange
Push $0
; Turn off old selected section
SectionGetFlags $1 $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags $1 $0
; Now remember the current selection
Push $2
StrCpy $2 $1
SectionGetFlags ${opplus41} $0
IntOp $0 $0 & ${SECTION_ON}
IntCmp $0 ${SECTION_ON} 0 +2 +2
StrCpy $1 ${opplus41}
SectionGetFlags ${opplus40} $0
IntOp $0 $0 & ${SECTION_ON}
IntCmp $0 ${SECTION_ON} 0 +2 +2
StrCpy $1 ${opplus40}
SectionGetFlags ${opstock2552} $0
IntOp $0 $0 & ${SECTION_ON}
IntCmp $0 ${SECTION_ON} 0 +2 +2
StrCpy $1 ${opstock2552}
StrCmp $2 $1 0 +4 ; selection hasn't changed
SectionGetFlags $1 $0
IntOp $0 $0 | ${SECTION_ON}
SectionSetFlags $1 $0
Pop $2
Pop $0
FunctionEnd