# Nullsoft Install System (NSIS) Script for Mount&Blade Mod Installation ; You'll notice comments start with a "#" or ";". ";" is more appropriate for commenting out whole lines. !define PRODUCT_NAME "Schattenländer" #The title of your mod goes here !define PRODUCT_FOLDER_NAME "Schattenländer" #The folder name for your mod; spaces are fine, just mind Windows restrictions (no /\:*?"<>| ) !define PRODUCT_VERSION "0.1c" #The mod version Name "${PRODUCT_NAME} v${PRODUCT_VERSION}" #The title given during setup of your mod, defaults to mod title and version OutFile "schattenlander_v${PRODUCT_VERSION}.exe" #The filename of the installer you're creating. Change "amazing_stuff_mod" to an 'internet friendly' version of your mod's title ;!define README_FILE "readme.txt" #Change "readme.txt" to your mod's readme filename, or comment out this line (with a ";") to not have "Show Readme" option at finish ;!define INSTALL_TEXT "installer.txt" #"installer.txt" contents will be displayed on the second (license) screen; comment out this line (with a ";") to have it skip that screen !define MUI_ICON "icons\scenery.ico" #Icon your installer will use !define MUI_UNICON "icons\knight-z4.ico" #Icon for the uninstaller (make SURE icon format is same as installer icon, can be same icon) # Optional Graphics # make ABSOLUTELY sure the BMP files used in the below lines exist if you uncomment the line, or installer creation will fail !define MUI_WELCOMEFINISHPAGE_BITMAP "installer_leftpane.bmp" #Large side bitmap for the Welcome page and the Finish page (should be 164x314 pixels) !define MUI_HEADERIMAGE #If this isn't defined, the below line does nothing. You should leave this line as it is. !define MUI_HEADERIMAGE_BITMAP "installer_toppane.bmp" #Small bitmap image to display in the top left corner of the header on all other pages (should be 150x57 pixels) !define CREATE_UNINSTALLER "no" #If you want an uninstaller to be created for your mod to be listed in Add/Remove Programs, change this to "yes" #You probably shouldn't edit below this point. #Really, I'm serious. Don't cry to me if you screw it up. ShowInstDetails show #It will show a progress text of files transferring when it installs ShowUnInstDetails show #Same goes for uninstall process !define PRODUCT_UNINST_ROOT_KEY "HKLM" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" ; MUI 1.67 compatible ------ !include "MUI.nsh" !include "WordFunc.nsh" !insertmacro WordFind ;!insertmacro StrFilter ; MUI Settings !define MUI_ABORTWARNING ; Language Selection Dialog Settings !define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}" !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language" ; Welcome page !insertmacro MUI_PAGE_WELCOME #First thing shown is welcome screen ; LICENSE PAGE ************************ !ifdef INSTALL_TEXT #If the install.txt is defined at the top of this file, !define MUI_LICENSEPAGE_BUTTON "Next >" #add in the "License" page between the welcome screen and directory screen !define MUI_LICENSEPAGE_TEXT_TOP "Installation Notes:" !define MUI_LICENSEPAGE_TEXT_BOTTOM "You should read the above for important notes about the mod, or special instructions." !insertmacro MUI_PAGE_LICENSE "${INSTALL_TEXT}" #Show license screen, with text read from "installer.txt" or whatever !endif ; Directory page !insertmacro MUI_PAGE_DIRECTORY #Then screen where is asks for install directory ; Instfiles page !insertmacro MUI_PAGE_INSTFILES #Then do actual install process ; Finish page !ifdef README_FILE #If the readme is set at the top, !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\${README_FILE}" #Go ahead and set it as the readme so that the "Show Readme" option is given !endif !insertmacro MUI_PAGE_FINISH #Then show finished screen ; Uninstaller pages !insertmacro MUI_UNPAGE_INSTFILES #For uninstaller creation ; Language files !insertmacro MUI_LANGUAGE "English" #Only english supported (could add more, but if the game is only in English, why?) ; MUI end ------ Function .onInit #This section gets MnB directory from registry and sets variables, when installer initializes ReadRegStr $R4 HKLM Software\Mount&Blade "" #R4 variable is MnB folder StrCmp $R4 "" 0 RegFine #If the Registry entry was blank, Mount&Blade wasn't found MessageBox MB_ICONSTOP|MB_OK "Mount&Blade installation directory could not be determined from Registry! You should make absolutely sure the installation path is correct when asked." StrCpy $R4 "$PROGRAMFILES\Mount&Blade" #Use default install path instead; hopefully it is correct RegFine: StrCpy $R6 "$R4\Modules\Native" #R6 variable is "Native" folder StrCpy $INSTDIR "$R4\Modules\${PRODUCT_FOLDER_NAME}" #INSTDIR is a globally used variable for the install dir FunctionEnd Function .onVerifyInstDir #These 6 lines make sure person installing selects a folder within ${WordFind} $INSTDIR "Modules\" "*" $R0 #the "Modules" directory, otherwise it disables the Install StrCmp $R0 $INSTDIR 0 NoAbort #button on the directory choice screen so they can't continue Abort NoAbort: FunctionEnd Section "MainSection" SEC01 #Once the actual install process starts, it does this section SetOutPath "$INSTDIR" #Set the output path to the global INSTDIR variable SetOverwrite on #Always overwrite files, no matter which is newer ${WordFind} $INSTDIR "\" "-1*}" $R7 #This line sets R7 to the output folder ("My Cool Mod" or whatever) ${WordFind} $INSTDIR "\Modules" "-2{*" $R0 #These 4 lines check to see if MnB folder changed (person might have another MnB installation) StrCmp $R4 $R0 ResetDone #if so, it resets variables StrCpy $R4 $R0 #Reset R4 MnB folder StrCpy $R6 "$R4\Modules\Native" #Reset R6 Native folder ResetDone: CreateDirectory "$INSTDIR" #Make sure the install folder exists, create it if not StrCmp $R7 "native" NativeContinue #This line checks if install folder is "Native", if so, goes to NativeContinue label below IfFileExists "$INSTDIR\SceneObj\*.*" NativeContinue #If there are already files here, no need to copy from Native CreateDirectory "$INSTDIR\SceneObj" #Make sure SceneObj subfolder exists, create it if not CopyFiles $R6\*.* $INSTDIR #Copy over all the files from the "Native" folder CopyFiles $R6\SceneObj\*.* $INSTDIR\SceneObj NativeContinue: SetOutPath "$INSTDIR\SceneObj" #Change the output path to the SceneObj folder, for Scene definition files File /nonfatal /x *.bak /x *.orig SceneObj\*.* #Don't fail creation if no SceneObj files are found; exclude BAK and ORIG files SetOutPath "$INSTDIR\Resource" #Change the output path to the Resource folder, for additional BRF files File /nonfatal /x *.bak /x *.orig Resource\*.* #Don't fail creation if no Resource files are found; exclude BAK and ORIG files SetOutPath "$INSTDIR\Textures" #etc. File /nonfatal /x *.bak /x *.orig Textures\*.* SetOutPath "$INSTDIR\Sounds" File /nonfatal /x *.bak /x *.orig Sounds\*.* SetOutPath "$INSTDIR\Music" File /nonfatal /x *.bak /x *.orig Music\*.* SetOutPath "$INSTDIR" #Change the output path back to the main mod folder #Below File line gets files in current folder of installer script and adds them to the installer #Then, when the installation actually takes place, it's also used to indicate the files to extract #It excludes ("/x ") some files, such as NSIS scripts (this file you're looking at), icons, zip files, etc. #The *.* at the end makes it include every file, besides those specific filetypes it has already excluded #"nonfatal" switch means installer creation won't fail if no valid files are found; useful for mods with only new SCO files File /nonfatal /x *.nsi /x *.ico /x *.zip /x *.exe /x *.rar /x *.bak /x *.orig /x installer.txt /x readme_installer.rtf *.* SectionEnd #Everything below this is related to the uninstaller created Section -Post #this stuff creates the uninstaller after installation process completes StrCmp $R7 "native" SkipUninstCreation #If the person installed to Native folder, don't create Uninstaller as it would delete all files in the Native folder... bad idea StrCmp ${CREATE_UNINSTALLER} "no" SkipUninstCreation #See if it's set (from the top of this file) to create uninstaller WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" SkipUninstCreation: SectionEnd Function un.onUninstSuccess #more stuff for uninstaller HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." FunctionEnd Function un.onInit #more stuff for uninstaller !insertmacro MUI_UNGETLANGUAGE MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2 Abort FunctionEnd Section Uninstall #what the uninstaller actually deletes... everything including the folder, dammit Delete "$INSTDIR\SceneObj\*.*" Delete "$INSTDIR\Resource\*.*" Delete "$INSTDIR\Textures\*.*" Delete "$INSTDIR\Sounds\*.*" Delete "$INSTDIR\Music\*.*" Delete "$INSTDIR\*.*" RMDir "$INSTDIR\SceneObj" RMDir "$INSTDIR\Resource" RMDir "$INSTDIR\Textures" RMDir "$INSTDIR\Sounds" RMDir "$INSTDIR\Music" RMDir "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" SetAutoClose true SectionEnd