Source Mod Installers: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
 
(62 intermediate revisions by 14 users not shown)
Line 1: Line 1:
{{Underlinked|date=January 2024}}
{{lang|Source Mod Installers}}
<small>Extra thanks to [[User:Garry Newman|Garry Newman]] for relaying the basics of a mod installer.</small>
For this, you need [http://nsis.sourceforge.net/ NSIS] and [http://hmne.sourceforge.net/ HM NIS Edit].
For this, you need [http://nsis.sourceforge.net/ NSIS] and [http://hmne.sourceforge.net/ HM NIS Edit].


Use the following code where:
{{note|To automate the file list, use the NSIS Script Wizard in HM NIS Edit, then copy the list to your <code>setup.nsi</code>.}}
* <code>##MODNAME##</code> is the Mod name.
 
* <code>##MODTEAM##</code> is the Mod's team.
{{note|You might want to be sure to include a [[Wikipedia:ZIP (file format)|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>##MODURL##</code> is the Mod's website.
=Code from setup.nsi=
* <code>##MODDIR##</code> is the Mod's root directory (i.e. <code>cstrike</code>).
<pre>!define PRODUCT_NAME "Mod's Name"
* <code>##INSTICO##</code> is the location on the local computer where the icon for the installer executable is.
!define PRODUCT_VERSION "Release Version"
* <code>##DESKICO##</code> is the location on the local computer where the icon for the desktop icon for the game is.
!define PRODUCT_PUBLISHER "Mod Team/Company Name"
* <code>##FILE1##</code> is the first file you wish to install in the mod folder.
!define PRODUCT_WEB_SITE "Mod Website"
* <code>##FILE2##</code> is the second file you wish to install in the mod folder.
 
* <code>##FILEX##</code> is the last file you wish to install in the mod folder.
!define APPID 220
<pre>!define PRODUCT_NAME "##MODNAME##"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "##MODTEAM##"
!define PRODUCT_WEB_SITE "##MODURL##"


;Remove this if you do not wish to have a custom desktop icon:
!define MODDIR "Mod's root directory"
!define DESKTOP_ICON
;(i.e. cstrike)


; MUI 1.67 compatible ------
!define LOCALDIR "C:\Program Files\Valve\Steam\SteamApps\SourceMods"
!include "MUI.nsh"
;This value should be set depending on the PC this will be compiled under


; MUI Settings
!define MUI_ICON "Installer Icon"
!define MUI_ABORTWARNING
;This is the location on the local computer where the icon for the installer executable is.
!define MUI_ICON "##INSTICO##"


; Welcome page
!define FULL_GAME_NAME "Full Game Name"
!insertmacro MUI_PAGE_WELCOME
;This is the name of the game defined in gameinfo.txt
; Directory page
;Remove all colons from this (as well as any other invalid char in a file name)
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES


; Language files
!define DESKICO "Desktop Icon"
!insertmacro MUI_LANGUAGE "English"
;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)


; MUI end ------
;Uncomment this if you do not wish to have a custom desktop icon:
;!define NO_DESKTOP_ICON


Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
;Uncomment this if you want to use ZipDLL
OutFile "Setup.exe"
;The zip file should be in the LOCALDIR for this
InstallDir ""
;!define ZIPDLL
ShowInstDetails show


Section "Mod" SEC01
;======DO NOT EDIT BEYOND THIS POINT======
  SetOverwrite ifdiff
  SetOutPath "$INSTDIR"
  File "##FILE1##"
  File "##FILE2##"
  File "##FILEX##"


!ifdef DESKTOP_ICON
!ifdef ZIPDLL
  SetOutPath "$1"
!include "zipdll.nsh"
  File "DESKICO"
!endif
!endif


SectionEnd
var ICONDIR
var STEAMEXE


!include "MUI.nsh"
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"


Function .onInit
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
        ReadRegStr $0 HKLM "Software\Valve\Steam" InstallPath
OutFile "${PRODUCT_NAME}.exe"
        IfErrors lbl_123 lbl_456
ShowInstDetails show


        lbl_456:
Section "Mod Files" FILES
                Goto lbl_done
SetOverwrite ifdiff
SetOutPath "$INSTDIR"
!ifdef ZIPDLL
File "${LOCALDIR}\${MODDIR}.zip"
StrCpy $R0 "$INSTDIR\${MODDIR}.zip"
ZipDLL::extractall "$R0" "$INSTDIR"
Delete "$R0"
!else
File /r "${LOCALDIR}\${MODDIR}"
!endif


        lbl_123:
!ifndef NO_DESKTOP_ICON
                ClearErrors
SetOutPath "$ICONDIR"
                StrCpy $0 "$PROGRAMFILES\Valve\Steam"
File "${DESKICO}"
        lbl_done:
                  StrCpy $INSTDIR "$0\SteamApps\SourceMods\MODDIR"
!ifdef DESKTOP_ICON
                  StrCpy $1 "$0\steam\games"
!endif
!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"
!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</pre>
FunctionEnd</pre>
==See Also==
 
=See also=
* [[Steam 3rd Party Mod Support]]
* [[Steam 3rd Party Mod Support]]
* [http://nsis.sourceforge.net/wiki/Main_Page NSIS Wiki]
* [http://nsis.sourceforge.net/wiki/ZipDLL_plug-in ZipDLL plug-in] &mdash; {{wiki|Zip}} decompression support
* [http://nsis.sourceforge.net/UnTGZ_plug-in UnTGZ plug-in] &mdash; {{wiki|Gzip}} & [[Bzip2]] decompression support
* [http://www.towofu.net/soft/e-aicon.php @icon sushi]
:It's a great free icon application. Supports XP icons.
* [http://www.iconxp.com/ IconXP]
:It's a great icon application with a trial version available
* [http://www.dodbits.com/dods/index.php/source-graphics/nsis-installlers NSIS Basic Installer For Steam Content and Mods. dodbits.com]
:This tutorial will make a step-by-step basic to advanced installer for steam games. Mostly for CS:S and Day of Defeat but can be used for any VALVe game that requires a installer to automatically find the Mods address in the Steam folders. Use for installing whole Mods, Maps, Models... any content you like. All tools used are FREEWARE with links to them in the articles.
* [http://www.jrsoftware.org/isdl.php Inno Setup]
An easy user-friendly GUI based setup compiler, very easy to setup for mods and other applications.
[[Category:Tutorials]]
[[Category:Tutorials]]
[[Category:Modding]]
[[Category:Publicity & Publication]]

Latest revision as of 09:43, 20 September 2024

Underlinked - Logo.png
This article needs more Wikipedia icon links to other articles to help Wikipedia icon integrate it into the encyclopedia. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024
English (en)Русский (ru)Translate (Translate)

Extra thanks to Garry Newman for relaying the basics of a mod installer.

For this, you need NSIS and HM NIS Edit.

Note.pngNote:To automate the file list, use the NSIS Script Wizard in HM NIS Edit, then copy the list to your setup.nsi.
Note.pngNote: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 PRODUCT_VERSION "Release Version"
!define PRODUCT_PUBLISHER "Mod Team/Company Name"
!define PRODUCT_WEB_SITE "Mod Website"

!define APPID 220

!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

;======DO NOT EDIT BEYOND THIS POINT======

!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 "${PRODUCT_NAME}.exe"
ShowInstDetails show

Section "Mod Files" FILES
	SetOverwrite ifdiff
	SetOutPath "$INSTDIR"
!ifdef ZIPDLL
	File "${LOCALDIR}\${MODDIR}.zip"
	StrCpy $R0 "$INSTDIR\${MODDIR}.zip"
	ZipDLL::extractall "$R0" "$INSTDIR"
	Delete "$R0"
!else
	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"
!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

It's a great free icon application. Supports XP icons.
It's a great icon application with a trial version available
This tutorial will make a step-by-step basic to advanced installer for steam games. Mostly for CS:S and Day of Defeat but can be used for any VALVe game that requires a installer to automatically find the Mods address in the Steam folders. Use for installing whole Mods, Maps, Models... any content you like. All tools used are FREEWARE with links to them in the articles.

An easy user-friendly GUI based setup compiler, very easy to setup for mods and other applications.