• Welcome to SC4 Devotion Forum Archives.

Installer script for the VDK Trains Vol09.

Started by vester, February 05, 2013, 05:02:34 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

vester

Hi Everybody


Could use some help with a NSIS installer script. Not the whole installer, more like the structure of it.

What I need is an installer to install my trains.
First the user should pick a skin.
Second if I he want a option extra car that changes with the choice of skin.

The user should also have the option of installing all the skins to a folder outside the plug-in folder.

Andreas

Maybe you should contact Steve ("z") from the NAM Team. He's currently in charge for creating the NAM installer, since he has a vast knowledge of NSIS programming (unlike me, who just tinkered around for hours and hours until something worked as I wanted to ;) ).
Andreas

vester

Have asked him. He was a little caught with the nam installer.
Carl did give me a positive answerd, but need the semester to be over first (that was in december).
Still hoping to hear from him.


What I am looking for is just the basic structure. Will do the main leg work myself.

vester

#3
So I finally got the script to do what I like, with some help from Anders at stackoverflow.com
Posting it here for others to use if needed.

Here is what I ended up with:
!define PRODUCT_NAME "VDK Train Mods - Vol. 09. North American Freight Engines"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "vester_DK"
!define PRODUCT_WEB_SITE "http://sc4devotion.com/forums/index.php?board=110.0"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"

SetCompressor /SOLID lzma
BrandingText "VDK Train Mods Vol 09 Installer"

!include "UMUI.nsh"
!include "Sections.nsh" ;SF_Select sættes til 1 heri.
!include "logiclib.nsh"

; Add splash screen
!define MUI_FINISHPAGE_TITLE_3LINES

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "VDKIcon.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP "images\VDK_UMUI installer_image.bmp"
!define UMUI_LEFTIMAGE_BMP "images\VDK_UMUI installer_image.bmp"
!define MUI_COMPONENTSPAGE_SMALLDESC

; Language Selection Dialog Settings
;:!define UMUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
;:!define UMUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define UMUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

; Welcome page
; Components page
!insertmacro MUI_PAGE_COMPONENTS
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_SHOWREADME "$DOCUMENTS\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\readme_vdk_train_mods vol09.htm"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
;!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; MUI end ------

Name "${PRODUCT_NAME}"
;Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "VDK_Train_Mods_Vol_9_Installer.exe"
InstallDir "$DOCUMENTS\SimCity 4\Plugins\VDK Automata BSC"
ShowInstDetails show
;ShowUnInstDetails show


Section "ReadMe files" README
SectionIn RO
  SetOutPath "$DOCUMENTS\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09"
  SetOverwrite ifnewer
  File "readme_vdk_train_mods vol09.htm"
SetOutPath "$DOCUMENTS\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\images"
  SetOverwrite ifnewer
  File "images\blank.gif"
  File "images\ARR.jpg"
  File "images\BN1.jpg"
  File "images\BN2.jpg"
  File "images\BNSF.jpg"
  File "images\CBQB.jpg"
  File "images\CBQR.jpg"
  File "images\Chessie.jpg"
  File "images\CN1.jpg"
  File "images\CN2.jpg"
  File "images\CNW.jpg"
  File "images\CG.jpg"
  File "images\CP1.jpg"
  File "images\CSX1.jpg"
  File "images\Erie.jpg"
  File "images\GN1.jpg"
  File "images\GN2.jpg"
  File "images\GN2.jpg"
  File "images\KCS1.jpg"
  File "images\Milw.jpg"
  File "images\MP1.jpg"
  File "images\MP2.jpg"
  File "images\NP1.jpg"
  File "images\NP2.jpg"
  File "images\NS1.jpg"
  File "images\NYC.jpg"
  File "images\PRRB.jpg"
  File "images\PRRG.jpg"
  File "images\PRRR.jpg"
  File "images\RL.jpg"
  File "images\RockIsland.jpg"
  File "images\SF1RS.jpg"
  File "images\SF2BS.jpg"
  File "images\SF3YS.jpg"
  File "images\SF4YB.jpg"
  File "images\SOO1.jpg"
  File "images\SOO2.jpg"
  File "images\SPBNCB.jpg"
  File "images\SPBWAzer.jpg"
  File "images\SPBWUP.jpg"
  File "images\SPDL.jpg"
  File "images\SPLarkSSRR.jpg"
  File "images\SRR1.jpg"
  File "images\UP1.jpg"
  File "images\Wabash.jpg"
  File "images\WSOR.jpg"
  File "images\Bonus.jpg"
SectionEnd

SectionGroup "Select a freight engine replacement mod" FER00
Section /o "Alaska Railroad (ARR)" FER01
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "Mods\FE Rep\VDK FE Rep ARR EMD E9.dat"
SectionEnd

Section /o "Burlington Norhtern, green (BN1)" FER02
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "Mods\FE Rep\VDK FE Rep BN1 EMD E9.dat"
SectionEnd

Section /o "Burlington Northern Exclusive (BN2)" FER03
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "Mods\FE Rep\VDK FE Rep BN2 EMD E9.dat"
SectionEnd

Section /o "Wisconsin & Southern (WSOR)" FER44
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "Mods\FE Rep\VDK FE Rep WSOR EMD E9.dat"
SectionEnd
SectionGroupEnd


SectionGroup "Select a steam engine replacement mod" SER00
Section /o "Alaska Railroad (ARR)" SER01
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "Mods\SE Rep\VDK SE Rep ARR EMD E9.dat"
SectionEnd

Section /o "Burlington Norhtern, green (BN1)" SER02
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "Mods\SE Rep\VDK SE Rep BN1 EMD E9.dat"
SectionEnd

Section /o "Burlington Northern Exclusive (BN2)" SER03
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "Mods\SE Rep\VDK SE Rep BN2 EMD E9.dat"
SectionEnd

Section /o "Wisconsin & Southern (WSOR)" SER44
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "Mods\SE Rep\VDK SE Rep WSOR EMD E9.dat"
SectionEnd
SectionGroupEnd


SectionGroup "Select one or more freight engine additional mods" FEA00

Section /o "Alaska Railroad (ARR)" FEA01
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "Mods\FE Add\VDK FE Add ARR EMD E9.dat"
SectionEnd

Section /o "Burlington Norhtern, green (BN1)" FEA02
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "Mods\FE Add\VDK FE Add BN1 a EMD E9.dat"
  File "Mods\FE Add\VDK FE Add BN1 b EMD E9.dat"
SectionEnd

Section /o "Burlington Northern Exclusive (BN2)" FEA03
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "Mods\FE Add\VDK FE Add BN2 EMD E9.dat"
SectionEnd

Section /o "Wisconsin & Southern (WSOR)" FEA44
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "Mods\FE Add\VDK FE Add WSOR a EMD E9.dat"
  File "Mods\FE Add\VDK FE Add WSOR b EMD E9.dat"
SectionEnd
SectionGroupEnd

SectionGroup "Select to make a copy of all the mods" ALL00
Section /o "Copy all Freight Engine Replacement mods" ALL01
  SetOutPath "$DOCUMENTS\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\Freight Engines Rep"
  SetOverwrite ifnewer
  File "Mods\FE Rep\VDK FE Rep ARR EMD E9.dat"
  File "Mods\FE Rep\VDK FE Rep BN1 EMD E9.dat"
  File "Mods\FE Rep\VDK FE Rep BN2 EMD E9.dat"
  File "Mods\FE Rep\VDK FE Rep WSOR EMD E9.dat"
SectionEnd

Section /o "Copy all Steam Engine Replacement mods" ALL02
  SetOutPath "$DOCUMENTS\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\Steam Engines Rep"
  SetOverwrite ifnewer
  File "Mods\SE Rep\VDK SE Rep ARR EMD E9.dat"
  File "Mods\SE Rep\VDK SE Rep BN1 EMD E9.dat"
  File "Mods\SE Rep\VDK SE Rep BN2 EMD E9.dat"
  File "Mods\SE Rep\VDK SE Rep WSOR EMD E9.dat"
SectionEnd

Section /o "Copy all Freight Engine Addtional mods" ALL03
  SetOutPath "$DOCUMENTS\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\Freight Engines Rep"
  SetOverwrite ifnewer
  File "Mods\FE Add\VDK FE Add ARR EMD E9.dat"
  File "Mods\FE Add\VDK FE Add BN1 a EMD E9.dat"
  File "Mods\FE Add\VDK FE Add BN1 b EMD E9.dat"
  File "Mods\FE Add\VDK FE Add WSOR b EMD E9.dat"
SectionEnd
SectionGroupEnd

; Section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${README} "Installs the ReadMe files."

  !insertmacro MUI_DESCRIPTION_TEXT ${ALL00} "Copys all mods to the folder: $\n ..\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\"
  !insertmacro MUI_DESCRIPTION_TEXT ${ALL01} "Copys all Freight Engine Replacement mods (FE Rep) to the folder: $\n ..\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\"
  !insertmacro MUI_DESCRIPTION_TEXT ${ALL02} "Copys all Steam Engine Replacement mods to (SE Rep) the folder: $\n ..\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\"
  !insertmacro MUI_DESCRIPTION_TEXT ${ALL03} "Copys all Freight Engine Additional mods (FE Add) to the folder: $\n ..\SimCity 4\LEX_Downloads\VDK\Train Mods Vol 09\"

  !insertmacro MUI_DESCRIPTION_TEXT ${FER00} "Select a Freight Engine replacement mod $\n (FE Rep)."
  !insertmacro MUI_DESCRIPTION_TEXT ${FER01} "Installs Alaska Railroad engine $\n (ARR)."
  !insertmacro MUI_DESCRIPTION_TEXT ${FER02} "Installs Burlington Norhtern, green $\n (BN1)."
  !insertmacro MUI_DESCRIPTION_TEXT ${FER03} "Installs Burlington Northern Exclusive $\n (BN2)."
  !insertmacro MUI_DESCRIPTION_TEXT ${FER44} "Installs Wisconsin & Southern $\n (WSOR)."

  !insertmacro MUI_DESCRIPTION_TEXT ${SER00} "Select a Steam Engine replacement mod $\n (SE Rep)."
  !insertmacro MUI_DESCRIPTION_TEXT ${SER01} "Installs Alaska Railroad engine $\n (ARR)."
  !insertmacro MUI_DESCRIPTION_TEXT ${SER02} "Installs Green Burlington Norhtern $\n (BN1)."
  !insertmacro MUI_DESCRIPTION_TEXT ${SER03} "Installs Burlington Northern Exclusive $\n (BN2)."
  !insertmacro MUI_DESCRIPTION_TEXT ${SER44} "Installs Wisconsin & Southern $\n (WSOR)."

  !insertmacro MUI_DESCRIPTION_TEXT ${FEA00} "Select one or more Freight Engine replacement mods $\n (FE Add)."
  !insertmacro MUI_DESCRIPTION_TEXT ${FEA01} "Installs Alaska Railroad engine $\n (ARR)."
  !insertmacro MUI_DESCRIPTION_TEXT ${FEA02} "Installs Green Burlington Norhtern $\n (BN1)."
  !insertmacro MUI_DESCRIPTION_TEXT ${FEA03} "Installs Burlington Northern Exclusive $\n (BN2)."
  !insertmacro MUI_DESCRIPTION_TEXT ${FEA44} "Installs Wisconsin & Southern $\n (WSOR)."
!insertmacro MUI_FUNCTION_DESCRIPTION_END

!macro RadioGroupOrNone_SelChange gid sidf sidl
Push $0
Push $1
Push $2
Push $3
Var /GLOBAL RGON_${gid}_SID
StrCpy $2 0
${For} $1 ${sidf} ${sidl}
    ${If} ${SectionIsSelected} $1
        IntOp $2 $2 + 1
    ${EndIf}
${Next}
${IfThen} $2 U< 2 ${|} StrCpy $RGON_${gid}_SID 0 ${|}
StrCpy $2 0
StrCpy $3 0
${For} $1 ${sidf} ${sidl}
    ${If} ${SectionIsSelected} $1
        ${If} $RGON_${gid}_SID = $1
            SectionGetFlags $1 $0
            IntOp $0 $0 & ${SECTION_OFF}
            SectionSetFlags $1 $0
        ${Else}
            IntOp $2 $2 + 1
            StrCpy $3 $1
        ${EndIf}
    ${EndIf}
${Next}
StrCpy $RGON_${gid}_SID $3
${If} $2 U> 1
    SectionGetFlags ${gid} $0
    IntOp $0 $0 & ${SECTION_OFF}
    SectionSetFlags ${gid} $0
    StrCpy $RGON_${gid}_SID 0
${EndIf}
Pop $3
Pop $2
Pop $1
Pop $0
!macroend

Function .onSelChange
!insertmacro RadioGroupOrNone_SelChange ${FER00} ${FER01} ${FER44}
!insertmacro RadioGroupOrNone_SelChange ${SER00} ${SER01} ${SER44}
FunctionEnd


The size of the installer images is 342 x 768 px.
Filename: VDK_UMUI installer_image.bmp