Back to dodbits.com
Copyright dodbits.com 2005            Copyright explained... FFS... show some damn backbone and make your own n00b  :)
Make an NSIS installer for DoD:S custom content.

Description: A simple ... but long step by step guide to make NSIS install creator make a basic installer that automatically finds the users dod folder (DOD:s).

The following will build a installer to add your custom content you have already packaged in a "dod" folder with all the files already placed in the correct sub folders.


1. The Programs and the Preparation you will need....

Install NSIS A Free windows installer package...

Install HM NIS EDIT A Free NSIS Editor, a much better GUI to use with NSIS.


Make your custom content as you would for a zip file, a lot of people place a dod folder in their zip, do it this way for the installer, place all your custom content inside a main folder called... 
dod  ... make sure all the subfolders and files are in the correct place. The installer will grab the dod folder and place it and all of it's contents in the users correct address...

C:\Program Files\Steam\SteamApps\emailname@hotmail.com\day of defeat source
OR
C:\Valve\Steam\SteamApps\emailname@hotmail.com\day of defeat source

That is the best part of this installer, those complicated addresses and the explanation of how to place them in the users correct folders are not required... the installer will find that address automatically :)

There is only one problem... the uninstaller will report the size of the users dod folder (in the Add/Remove screen) ... not the true size of your content. You should make the user aware of this in a readme.



2. Use the wizard in  HM NIS EDIT....

Run the wizard in  HM NIS EDIT (click on the magic wand below "File")

Press next and...

Fill out the text boxes in the "Application Information" screen.

Press next.







3. The Five sections to be filled out in the "Setup options" screen...


Setup icon:
The icon the installer will use... this can be changed or use the default. To change you must have a working icon (.ico) compatable with NSIS and put in it's address on your local PC.

Setup file:
The name the icon will receive once you compile the installer.
NOTE: It maybe wise to give it a unique name other than "Setup.exe".


Setup Lang:
Select Languages.Leave alone if you wish.

GUI:
The look of the installer... modern looks best (for me anyway).

Compress:
Leave it on default "zlib" ...works fine. Press next.


4. Application directory and License screen.


This section holds info on the place the installer is going to put the files you made and a text page of a "License"...

Application default directory:
The one you see now will make the installer find the "Programs File" directory.

We want to find the users "day of defeat source\dod" folder.
There is more to do on this latter... but for now put in...


$INSTDIR



The little tick box:
This is below "Application default directory".
It is allways wise to leave the "Allow user to change the application directory" tick box as ticked. This will allow the user to use the browse button to choose for him/herself.


License file:
You dont have to have a "License". To make it go away, delete whats in there and leave it blank.

Press next.
5. Application Files screen.


This section can add information of the files you have made. It can make a optional selection section with info (the user hovers his mouse over the text of the title/tick box).

It also tells the installer where to find the files on your local PC.


You can allow the user choose files to install by unticking boxes when this section appears at the time of install. I will explain more on that section in another part of the tutiorial latter... go here if you are installing a multipule file optional install.

We are just making a simple one for now that only has one VTF file for a custom crosshair, so...

Untick the "Allow user to select the components to install" radio button.

Go to the text box on the right hand side, click on the example files and delete them. (press the big X button).

Now press the icon that looks like a File directory tree. The edit directory box pops up.
Press the browse (...) icon and navigate to the dod folder where your custom content is held. Press OK.

Press Next.
6. Application Icons screen.


This section is about the Start menu it can create a program group with a uninstall icon and a web address.

For this simple Tutorial we will opt out and keep it simple...


Application Start Menu folder name:
just delete the name leave it blank.

Radio buttons:
Unclick all ticks in the three options below that.

Press next.
7. Execute after set up screen.


This next section is used to execute the program after install.

For our needs, custom content, we don't need to do this... leave it blank.

It can also show a readme, make one if you like
but it is far better to include it in a zip with the install program. The user should read about your custom content before he starts to install.

For this tutorial we will leave all sections here blank.

Press next.
8. Uninstaller screen.

This section is for the uninstaller details, it is a good idea to include this as they often work well for "new users to the game" oh to hell with it... n00bs OK?

We do have to do some work in the script latter for the users uninstalling convenience, but for now...

Use uninstaller tick box:
Make sure "Use uninstaller" is ticked.

Uninstall prompt:
Leave this alone.


Uninstall success:
Leave this alone.


Uninstall icon:
Leave this alone for now. We will rename it latter.

Press next.
9. Wizard Finished screen and saving the script.


The Wizard Finished screen pops up...  Press Finish.

We are now out of the wizard and back into HM NIS EDIT.
Your script is in the right window pane.

Now is a good time to save the file, name it what you want press "Save as..." in "File". The save box pops up place it somewhere you can find it again and give it a name.

The same folder you have your content in will be fine.

We are not finished yet!


  What we have just done is make a installer script that is ready to compile and run.

  It is not quite ready yet, if we compile and run it now it will...

* Not find the dod folder automatically... we have manually add a section in the script.

* It will create problems with uninstalling custom content... we need to manually alter some     information in the script, if you make more custom content the uninstaller icon will overwrite other uninstallers in the dod folder. That will be bad!

The next section deals with the final tidy up of the script.

The steps we have just taken seem long, when you have done this a few times it can take under 2 miniutes!

Let's continue and clean up that script.
10. Inserting the auto find steam folder script.

You can test it now but we are not done yet. The installer still can't find the dod folder by itself.

A "Function" needs to be in the script.


* Find this line in the script... "; MUI end ------" 
It will be around line 34... this is noted on the bottom left of HM NIS EDIT.

Copy all the text in this link.

* Click under... "; MUI end ------"

* Press enter a couple of times to give it a bit of space from the other sections.

* Paste the text in.

OK, basically the script will now work if you compile it... BUT!

One more very important thing for people who are going to make a lot of content! The Uninstaller still needs fixing.

                              11. The Un-installer problem.

If you make MORE of these installers WITH Un-installers for files that will end up in the dod folder a bad thing will occur.

I have found that if you make a uninstaller icon ...you never make one with the same name.

Make it a unique name. If you don't the next installer you make will install the same icon with the same default name in the dod folder.

This is bad. The new Uninstall icon will overwrite the old one and cause problems and make a small mess of the users dod folder.

The solution is to rename the icon now with a unique name.


* Find this section in your script (around line 122) ...

Section -Post
  WriteUninstaller "$INSTDIR\uninst.exe"
  WriteRegStr ....
(The script goes on...blah blah. Removed for this tutorial)

Think of a unique name to idenify your custom content... rename the icon like this..

Section -Post
  WriteUninstaller "$INSTDIR\
uninstINsanexhair.exe"


There are two more places you need to do this...


* The first of these is in this same section...

(Section -Post)

Find it at the end of the thrid line in this section (
around line 124)  ...rename with the same name you used in "Section -Post"


* The last one is in...

(Section Uninstall)

Find it at the end of the First line in this section (
around line 142). ...rename with the same name you used in "Section -Post"

Save the script again to save the changes you just made.
12. You are done, time to compile and test.

Now... it is ready to compile a script to make a installer that will...

* Find the dod folder by searching the users registry, complete the correct folder address for install.

* Create folders/sub folders and place the files correctly.

* When the user doesn't want your stuff any more... he can remove it by a quick visit to the Add/Remove programs list in the control panel or the dod folder.


The last step is to compile (this will make a installer package) and run it to test it.

Go to "NSIS" in HM NIS EDIT select "Compile and Run"
13. Checking your work.

Make sure it finds the dod folder, Install it, then check the files are in the right place.

Try the un-installer in the control panel. Make sure all the files go (it may leave empty folders, but no files. This is ok). Make sure the uninstaller icon in the dod directory is also gone.

The installer package will be in the same folder you saved the script in. Its name will be the one you gave it in step 9 of this tutorial.

Thank god that's over.