Source Mod Installers: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		 Note:To automate the file list, use the NSIS Script Wizard in HM NIS Edit, then copy the list to your
Note:To automate the file list, use the NSIS Script Wizard in HM NIS Edit, then copy the list to your 
 Note:You might want to be sure to include a ZIP-compressed version of the mod as a download. This will make it so people who are uneasy with EXE files able to get the mod.
Note:You might want to be sure to include a ZIP-compressed version of the mod as a download. This will make it so people who are uneasy with EXE files able to get the mod.
		
	
| m (→See Also:  @icon sushi) | |||
| Line 8: | Line 8: | ||
| =Code from setup.nsi= | =Code from setup.nsi= | ||
| <pre>!define PRODUCT_NAME "Mod's Name" | <pre>!define PRODUCT_NAME "Mod's Name" | ||
| !define APPID 220 | |||
| !define PRODUCT_VERSION "Release Version" | !define PRODUCT_VERSION "Release Version" | ||
| Line 17: | Line 19: | ||
| !define MODDIR "Mod's root directory" | !define MODDIR "Mod's root directory" | ||
| ;(i.e. cstrike) | ;(i.e. cstrike) | ||
| !define LOCALDIR "C:\Program Files\Valve\Steam\SteamApps\SourceMods" | |||
| ;This value should be set depending on the PC this will be compiled under | |||
| !define MUI_ICON "Installer Icon" | !define MUI_ICON "Installer Icon" | ||
| Line 34: | Line 39: | ||
| ;Uncomment this if you want to use ZipDLL | ;Uncomment this if you want to use ZipDLL | ||
| ;The zip file should be in the LOCALDIR for this | |||
| ;!define ZIPDLL | ;!define ZIPDLL | ||
| Line 53: | Line 59: | ||
| ShowInstDetails show | ShowInstDetails show | ||
| Section "Mod Files"  | Section "Mod Files" FILES | ||
| 	SetOverwrite ifdiff | 	SetOverwrite ifdiff | ||
| !ifdef ZIPDLL | !ifdef ZIPDLL | ||
| 	File " | 	File "${LOCALDIR}\${MODDIR}.zip" | ||
| 	StrCpy $R0 "$INSTDIR\ | 	StrCpy $R0 "$INSTDIR\${MODDIR}.zip" | ||
| 	ZipDLL::extractall "$R0" "$INSTDIR" | 	ZipDLL::extractall "$R0" "$INSTDIR" | ||
| 	Delete "$R0" | 	Delete "$R0" | ||
| !else | !else | ||
| 	SetOutPath "$INSTDIR" | 	SetOutPath "$INSTDIR" | ||
| 	File /r "${LOCALDIR}\${MODDIR}" | |||
| 	File /r " | |||
| !endif | !endif | ||
| Line 73: | Line 78: | ||
| SectionEnd | SectionEnd | ||
| !ifndef NO_DESKTOP_ICON | !ifndef NO_DESKTOP_ICON | ||
| Section "Desktop Shortcut"  | Section "Desktop Shortcut" SHORTCUT | ||
| 	SetOutPath "$DESKTOP" | 	SetOutPath "$DESKTOP" | ||
| 	CreateShortcut "${FULL_GAME_NAME}.lnk" $STEAMEXE \ | 	CreateShortcut "${FULL_GAME_NAME}.lnk" $STEAMEXE \ | ||
| 		'-applaunch  | 		'-applaunch ${APPID} -game "$INSTDIR"' "$ICONDIR\${FULL_GAME_NAME}.ico" | ||
| SectionEnd | SectionEnd | ||
| !endif | !endif | ||
| Line 90: | Line 95: | ||
| !ifndef NO_DESKTOP_ICON | !ifndef NO_DESKTOP_ICON | ||
| 	StrCpy $ICONDIR "$R0\steam\games" | 	StrCpy $ICONDIR "$R0\steam\games" | ||
| 	SectionSetFlags ${ | 	SectionSetFlags ${SHORTCUT} 0 | ||
| 	StrCpy $STEAMEXE "$R0\steam.exe" | |||
| !endif | !endif | ||
| 	SectionSetFlags ${ | 	SectionSetFlags ${FILES} 17 | ||
| 	Return | 	Return | ||
| 	lbl_error: | 	lbl_error: | ||
| 		ClearErrors | 		ClearErrors | ||
| 		SectionSetFlags ${ | 		SectionSetFlags ${FILES} 17 | ||
| FunctionEnd</pre> | FunctionEnd</pre> | ||
Revision as of 17:53, 26 June 2006
Extra thanks to Garry Newman for relaying the basics of a mod installer.
For this, you need NSIS and HM NIS Edit.
 Note:To automate the file list, use the NSIS Script Wizard in HM NIS Edit, then copy the list to your
Note:To automate the file list, use the NSIS Script Wizard in HM NIS Edit, then copy the list to your setup.nsi. Note:You might want to be sure to include a ZIP-compressed version of the mod as a download. This will make it so people who are uneasy with EXE files able to get the mod.
Note:You might want to be sure to include a ZIP-compressed version of the mod as a download. This will make it so people who are uneasy with EXE files able to get the mod.Code from setup.nsi
!define PRODUCT_NAME "Mod's Name"
!define APPID 220
!define PRODUCT_VERSION "Release Version"
!define PRODUCT_PUBLISHER "Mod Team/Company Name"
!define PRODUCT_WEB_SITE "Mod Website"
!define MODDIR "Mod's root directory"
;(i.e. cstrike)
!define LOCALDIR "C:\Program Files\Valve\Steam\SteamApps\SourceMods"
;This value should be set depending on the PC this will be compiled under
!define MUI_ICON "Installer Icon"
;This is the location on the local computer where the icon for the installer executable is.
!define FULL_GAME_NAME "Full Game Name"
;This is the name of the game defined in gameinfo.txt
;Remove all colons from this (as well as any other invalid char in a file name)
!define DESKICO "Desktop Icon"
;This is the location on the local computer where the icon for the desktop icon for the game is.
;The icon name must be the same as the one in gameinfo.txt
;Remove all colons from this (as well as any other invalid char in a file name)
;Uncomment this if you do not wish to have a custom desktop icon:
;!define NO_DESKTOP_ICON
;Uncomment this if you want to use ZipDLL
;The zip file should be in the LOCALDIR for this
;!define ZIPDLL
!ifdef ZIPDLL
	!include "zipdll.nsh"
!endif
var ICONDIR
var STEAMEXE
!include "MUI.nsh"
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
ShowInstDetails show
Section "Mod Files" FILES
	SetOverwrite ifdiff
!ifdef ZIPDLL
	File "${LOCALDIR}\${MODDIR}.zip"
	StrCpy $R0 "$INSTDIR\${MODDIR}.zip"
	ZipDLL::extractall "$R0" "$INSTDIR"
	Delete "$R0"
!else
	SetOutPath "$INSTDIR"
	File /r "${LOCALDIR}\${MODDIR}"
!endif
!ifndef NO_DESKTOP_ICON
	SetOutPath "$ICONDIR"
	File "${DESKICO}"
!endif
SectionEnd
!ifndef NO_DESKTOP_ICON
Section "Desktop Shortcut" SHORTCUT
	SetOutPath "$DESKTOP"
	CreateShortcut "${FULL_GAME_NAME}.lnk" $STEAMEXE \
		'-applaunch ${APPID} -game "$INSTDIR"' "$ICONDIR\${FULL_GAME_NAME}.ico"
SectionEnd
!endif
Page custom Finish
Function Finish
  MessageBox MB_OK|MB_ICONEXCLAMATION "Steam must be restarted for the game to show on the games list."
FunctionEnd
Function .onInit
	ReadRegStr $R0 HKLM "Software\Valve\Steam" InstallPath
	ReadRegStr $R1 HKCU "Software\Valve\Steam" SourceModInstallPath
	IfErrors lbl_error 0
	StrCpy $INSTDIR "$R1\${MODDIR}"
!ifndef NO_DESKTOP_ICON
	StrCpy $ICONDIR "$R0\steam\games"
	SectionSetFlags ${SHORTCUT} 0
	StrCpy $STEAMEXE "$R0\steam.exe"
!endif
	SectionSetFlags ${FILES} 17
	Return
	lbl_error:
		ClearErrors
		SectionSetFlags ${FILES} 17
FunctionEnd
See Also
- Steam 3rd Party Mod Support
- NSIS Wiki
- ZipDLL — Use this to possibly compress your installer
- @icon sushi
- It's a great free icon application. Supports XP icons.
- It's a great icon application with a trial version available