Source Mod Installers: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
{{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 certain people who do not like third-party setup files will be able to get the mod.}}
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].


Line 14: Line 12:
* <code>##FILE2##</code> is the second file you wish to install in the mod folder.
* <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.
* <code>##FILEX##</code> is the last file you wish to install in the mod folder.
{{note|To automate the FILE1-FILEX list, use the NSIS Script Wizard in HM NIS Edit, then copy the list to your <code>setup.nsi</code>.}}
{{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 certain people who do not like third-party setup files will be able to get the mod.}}
=Code from setup.nsi=
<pre>!define PRODUCT_NAME "##MODNAME##"
<pre>!define PRODUCT_NAME "##MODNAME##"
!define PRODUCT_VERSION "##MODVERSION##"
!define PRODUCT_VERSION "##MODVERSION##"

Revision as of 18:15, 21 October 2005

For this, you need NSIS and HM NIS Edit.

Use the following code where:

  • ##MODNAME## is the Mod name.
  • ##MODVERSION## is the installer's release version.
  • ##MODTEAM## is the Mod's team.
  • ##MODURL## is the Mod's website.
  • ##MODDIR## is the Mod's root directory (i.e. cstrike).
  • ##INSTICO## is the location on the local computer where the icon for the installer executable is.
  • ##DESKICO## is the location on the local computer where the icon for the desktop icon for the game is.
  • ##FILE1## is the first file you wish to install in the mod folder.
  • ##FILE2## is the second file you wish to install in the mod folder.
  • ##FILEX## is the last file you wish to install in the mod folder.
Note.pngNote:To automate the FILE1-FILEX 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 certain people who do not like third-party setup files will be able to get the mod.

Code from setup.nsi

!define PRODUCT_NAME "##MODNAME##"
!define PRODUCT_VERSION "##MODVERSION##"
!define PRODUCT_PUBLISHER "##MODTEAM##"
!define PRODUCT_WEB_SITE "##MODURL##"

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

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "##INSTICO##"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
InstallDir ""
ShowInstDetails show

Section "Mod" SEC01
  SetOverwrite ifdiff
  SetOutPath "$INSTDIR"
  File "##FILE1##"
  File "##FILE2##"
  File "##FILEX##"

!ifndef NO_DESKTOP_ICON
  SetOutPath "$2"
  File "DESKICO"
!endif

SectionEnd


Function .onInit
         ReadRegStr $0 HKLM "Software\Valve\Steam" InstallPath
         ReadRegStr $1 HKCU "Software\Valve\Steam" SourceModInstallPath
         IfErrors lbl_123 lbl_456

         lbl_456:
                 Goto lbl_done
         lbl_123:
                 ClearErrors
                 StrCpy $0 "$PROGRAMFILES\Valve\Steam"
                 Goto lbl_end
         lbl_done:
                 StrCpy $INSTDIR "$1\##MODDIR##"
                 Goto lbl_end
         lbl_end:
!ifndef NO_DESKTOP_ICON
                 StrCpy $2 "$0\steam\games"
!endif
FunctionEnd

See Also