Saturday, March 10, 2007

Installer for Mod Wars

One of the things I want to do with this project is setup all sorts of tools that you'd expect to find in a commercial development shop such as version control, bug / feature tracking, automated builds, continuous integration, unit tests, and installers.

Setting up all of these systems will be a ttime consuming process because:
  • There are lots of tools available, so evaluation time is needed
  • Whichever tools I pick, there will be a learning curve
I took a long, hard look at all of the systems that I wanted to put in place and I priorised them. My criteria for defining importance were:
  • Will this tool / system affect the player?
  • Will this tool / system become more difficult to implement as time passes?
Based on that criteria, here is my priority list:
  • Installer for the client
  • Bug / Feature tracking system
  • Automated build tools
  • Continuous integration system
  • Unit testing
  • Code coverage tools
  • Logging
  • Code verification tools
Phew! Quite a list. As you can see the installer came out top of the list. The software industry is a tough place to be because there are so many competitors out there and games is no exception; there's a ton of free games to download. Therefore I want to make it as easy as possible for players to play my game, and that means making a nice simple installer for them. Plus of course, this is a tool that will become more difficult to implement as the project grows in complexity and incorporates libraries and data files. Therefore I decided to jump in right now while the install process needs just three files.

I looked at several tools:

1) Inno Setup: http://www.jrsoftware.org/isinfo.php
2) Nullsoft Scriptable Installer: http://nsis.sourceforge.net/Main_Page
3) MSBuild: http://msdn2.microsoft.com/en-us/library/wea2sca5.aspx
4) WiX: http://wix.sourceforge.net/
5) Spoon Installer: http://sourceforge.net/projects/spoon-installer

Actually, after a cursory look at their respective websites the only tools I looked at in any detail were Inno and Nullsoft (NSIS). I looked at Inno first and quickly got a bit stuck due to lack of documentation. NSIS on the other hand came with a full manual and I found a whole bunch of tutorials on the web so I had a bash at that one.

An hour later I have a fully working installer with corresponding uninstaller. Cool eh :-) Here's the code:


; name the installer
Name "Mod Wars Setup"

;the install program
OutFile "mw_setup.exe"

;installation directory
InstallDir "$PROGRAMFILES\Mod Wars\"

; define a variable for the bin directory

;==============================================================================
; Install section
;==============================================================================
Section

; set install directory
SetOutPath $INSTDIR

;Files to install
File "/oname=modwars.exe" "..\..\bin\mw_client_wx.exe"
File "..\..\bin\SDL.dll"
File "..\..\bin\SDL_gfx.dll"

; create uninstaller file
WriteUninstaller "$INSTDIR\unins_mw.exe"

; create shortcuts
CreateDirectory "$SMPROGRAMS\Mod Wars\"
CreateShortCut "$SMPROGRAMS\Mod Wars\Mod Wars.lnk" "$INSTDIR\modwars.exe"
CreateShortCut "$SMPROGRAMS\Mod Wars\Uninstall Mod Wars.lnk" "$INSTDIR\unins_mw.exe"

; default section end
SectionEnd

;==============================================================================
;Uninstall section
;==============================================================================
Section "Uninstall"

; always delete uninstaller first
Delete "$INSTDIR\unins_mw.exe"

; delete all installed files
Delete "$INSTDIR\modwars.exe"
Delete "$INSTDIR\SDL.dll"
Delete "$INSTDIR\SDL_gfx.dll"

;delete shortcuts
Delete "$SMPROGRAMS\Mod Wars\Mod Wars.lnk"
Delete "$SMPROGRAMS\Mod Wars\Uninstall Mod Wars.lnk"
RMDir "$SMPROGRAMS\Mod Wars\"

; finally, remove install directory
RMDir "$INSTDIR"

SectionEnd

No comments: