How to create a mod installer

From AOW HT Wiki

A MOD installer allows you to directly copy your mod files where Act of War - High Treason is installed without having to search yourself or to explain where it is.
It also creates an uninstall file which can delete all installed files for this MOD.
This installer allows also to install your MOD only if your game is on Patch 1.
As the installer used the lzma compression algorithm, the size is much shorter than the zip equivalent.

Contents

Installation script explained

In order to create your mod installer you have to use Inno Setup ( you can download this freeware here : [1])
Once Inno Setup is installed, you modify modinstaller.iss - the code file appearing at the end of the page - to compile your own installer as shown below.

MOD name and MOD version configuration

<xml>[Setup]
AppName                 = NavyInvader_1-0-0 Mod
AppVerName              = NavyInvader_1-0-0 Mod
</xml>

You have to type here the name and the version of your mod.
These values will be used for naming your mod during the install and the uninstall and for directories creation in the Start Menu folder.

MOD files configuration

<xml>[Files]
; type in the Source field the full path of the file you want to install between double quotes as the example below
Source: "C:\Program Files\Atari\Act of War - High Treason\Mods\NavyInvader_1-0-0.aowmod"; DestDir: "{app}\Mods"
Source: "C:\Program Files\Atari\Act of War - High Treason\Mods\NavyInvader_1-0-0.aowmod.md5sums"; DestDir: "{app}\Mods"
Source: "C:\Program Files\Atari\Act of War - High Treason\Mods\NavyInvader_1-0-0.txt"; DestDir: "{app}\Mods"; Flags: isreadme
</xml>

Here you just need to change the source field.
The Source field must be the FULL PATH of your mod files. You must have a line like this for each file you want to install.
In this example the NavyInvader_1-0-0.txt file is a copy of the Info file you have in the ModManager Info menu.

Start Menu entries icon configuration

<xml>[Icons]
; replace all NavyInvader_1-0-0 by the name of your mod
Name: "{group}\Mods\NavyInvader_1-0-0\NavyInvader_1-0-0"; FileName: "{app}\ActOfWar_HighTreason.exe"; Parameters: "-ModName=""NavyInvader_1-0-0"""
Name: "{group}\Mods\NavyInvader_1-0-0\NavyInvader_1-0-0.txt"; FileName: "{app}\Mods\NavyInvader_1-0-0.txt"
Name: "{group}\Mods\NavyInvader_1-0-0\Uninstall NavyInvader_1-0-0"; FileName: "{uninstallexe}"
</xml>

These icons are in fact the icons displayed in the Start Menu folder.
The first one is a link to the mod launcher.
The second one is a link to the mod info text file.
The third one is a link to the mod uninstaller.
You just have to replace here NavyInvader_1-0-0 with the name of your mod each time you see it.

Launch MOD after installation configuration

<xml>[Run]
; replace NavyInvader_1-0-0 by the name of your mod
FileName: "{app}\ActOfWar_HighTreason.exe"; Parameters: "-ModName=""NavyInvader_1-0-0"""; Description: "Launch mod"; Flags: postinstall
</xml>

This part of the file is used for having the possibility to launch the mod after the installation.
Such as the Parameters field in the [Icons] section, you just have to change the name of the mod - here "NavyInvader_1-0-0".

Once all theses changes done, DO NOT MODIFY THE CODE BELOW.
To create the installer you just need to compile this file with Inno Setup and the installer will be created in the Output folder located where you have saved the .iss file.

Full ISS Sample file

Here is a copy of modinstaller.iss

 [Setup]
 ; the AppName value is the name which will be displayed during the mod installation
 ; The AppVername is the version name of your mod
 AppName                 = NavyInvader_1-0-0 Mod
 AppVerName              = NavyInvader_1-0-0 Mod
 DefaultDirName          = {code:GetExtractedOrDefaultAowPath}
 DefaultGroupName        = {code:GetExtractedOrDefaultAowGroup}
 DisableDirPage          = yes
 DisableProgramGroupPage = yes
 Compression             = lzma
 
 [Languages]
 Name: "EN"; MessagesFile: "compiler:Default.isl"
 Name: "FR"; MessagesFile: "compiler:Languages\French.isl"
 Name: "DE"; MessagesFile: "compiler:Languages\German.isl"
 Name: "IT"; MessagesFile: "compiler:Languages\Italian.isl"
 
 [Files]
 ; type in the Source field the full path of the file you want to install between double quotes as the example below
 Source: "C:\Program Files\Atari\Act of War - High Treason\Mods\NavyInvader_1-0-0.aowmod"; DestDir: "{app}\Mods"
 Source: "C:\Program Files\Atari\Act of War - High Treason\Mods\NavyInvader_1-0-0.aowmod.md5sums"; DestDir: "{app}\Mods"
 Source: "C:\Program Files\Atari\Act of War - High Treason\Mods\NavyInvader_1-0-0.txt"; DestDir: "{app}\Mods"; Flags: isreadme
 
 [Icons]
 ; replace all NavyInvader_1-0-0 by the name of your mod
 Name: "{group}\Mods\NavyInvader_1-0-0\NavyInvader_1-0-0"; FileName: "{app}\ActOfWar_HighTreason.exe"; Parameters: "-ModName=""NavyInvader_1-0-0"""
 Name: "{group}\Mods\NavyInvader_1-0-0\NavyInvader_1-0-0.txt"; FileName: "{app}\Mods\NavyInvader_1-0-0.txt"
 Name: "{group}\Mods\NavyInvader_1-0-0\Uninstall NavyInvader_1-0-0"; FileName: "{uninstallexe}"
 
 [Run]
 ; replace NavyInvader_1-0-0 by the name of your mod
 FileName: "{app}\ActOfWar_HighTreason.exe"; Parameters: "-ModName=""NavyInvader_1-0-0"""; Description: "Launch mod"; Flags: postinstall
 
 [Code]
 var
    gAowPath          : string;
    gAowPathFound     : boolean;
    gLastPatchVersion : integer;
    gloISTages        : boolean;
 //------------------------------------------------------------------------------
 //******************************************************************************
 //------------------------------------------------------------------------------
 function GetLangueString : string;
 begin
      result := UpperCase(ExpandConstant('{language}'));
 end;
 //--------------------------------------------------------------
 function IsLangue( parLangue: string) : boolean;
 begin
    result := parLangue = GetLangueString;
 end;
 //--------------------------------------------------------------
 function IsActOfPathCorrect( parPath : string) : boolean;
 begin
      result := false;
      if DirExists(parPath) and
         FileExists(parPath + '\ActOfWar_HighTreason.exe') then
      begin
           result := true;
      end;
 end;
 //------------------------------------------------------------------------------
 function GetThisPatchNumber : integer;
 begin
      result := 10;
 end;
 //------------------------------------------------------------------------------
 function GetPatchVersionInfoFileName : string;
 begin
      result := gAowPath + '\PatchVersion.nfo';
 end;
 //------------------------------------------------------------------------------
 function __GetExtractedAowPath_ROK( var parPath : string) : boolean;
 var
    locCandidateAowPath : String;
 begin
      if RegQueryStringValue(HKEY_CURRENT_USER, 'Software\Eugen Systems\ActOfWar_HighTreason','AppDir',locCandidateAowPath) and
         IsActOfPathCorrect(locCandidateAowPath) then
      begin
           result := true;
           parPath := locCandidateAowPath;
      end
      else
      begin
           result :=  false;
           parPath := ;
      end;
 end;
 //------------------------------------------------------------------------------
 function GetExtractedOrDefaultAowPath(Param : string) : string;
 var
    locCandidateAowPath : String;
 begin
      if __GetExtractedAowPath_ROK(locCandidateAowPath) then
      begin
           result := locCandidateAowPath;
      end
      else
      begin
           result :=  ExpandConstant('{pf}') + '\Atari\Act of War - High Treason';
      end;
 end;
 //------------------------------------------------------------------------------
 function  GetExtractedOrDefaultAowGroup( parFile : string) : string;
 var
   locGroup : string;
 begin
      result := 'Atari\Act Of War - High Treason'
 end;
 //------------------------------------------------------------------------------
 function ExtractAowPath_ROK : boolean;
 var
    locCandidateAowPath : String;
 begin
      result := false;
      if RegQueryStringValue(HKEY_CURRENT_USER, 'Software\Eugen Systems\ActOfWar_HighTreason','AppDir',locCandidateAowPath) then
      begin
           gAowPath := locCandidateAowPath;
           result   := IsActOfPathCorrect(gAowPath);
      end; 
 end;
 //------------------------------------------------------------------------------
 function ReadCurrentPatchNumber( var parVersionNumber : integer) : boolean;
 var
   locVersionPatchString : string;
 begin
      result := false;
      parVersionNumber := 0;
      if FileExists( GetPatchVersionInfoFileName ) then
      begin
           if LoadStringFromFile(GetPatchVersionInfoFileName, locVersionPatchString) then
           begin
                parVersionNumber := StrToIntDef(locVersionPatchString, -1);
                if parVersionNumber > 0 then
                begin
                     result := true;
                end;
           end;
      end
      else
      begin
           result := false;
      end;
 end;
 //------------------------------------------------------------------------------
 //******************************************************************************
 //------------------------------------------------------------------------------
 function GetMessage_CorruptedInstall : string;
 var
    locLangue : string;
 begin
      locLangue := GetLangueString;
      if locLangue = 'FR' then
      begin
           result := 'Échec. Impossible de trouver la mise à jour Act of War - High Treason.  Les données semblent corrompues.  Veuillez réinstaller le jeu.';
      end
      else if locLangue = 'DE' then
      begin
           result := 'Abbruch, da die aktuelle Patchversion von Act of War - High Treason nicht gefunden werden kann. Daten scheinen beschädigt zu sein, bitte installieren Sie das Spiel neu.';
      end
      else
      begin
           result := 'Unable to find the Act of War - High Treason current patch version, aborting. Data seems corrupted, please reinstall the game.';
      end;
 end;
 //------------------------------------------------------------------------------
 function GetMessage_VersionMismatchPatch : string;
 var
    locLangue : string;
 begin
      locLangue := GetLangueString;
      if locLangue = 'FR' then
      begin
           result := 'Vous navez pas installé la bonne version dAct of War - High Treason.';
      end
      else if locLangue = 'DE' then
      begin
           result := 'Sie haben nicht die richtige Version von Act of War - High Treason.';
      end
      else
      begin
           result := 'You have not the good version of Act of War - High Treason version';
      end;
 end;
 //------------------------------------------------------------------------------
 function AOWIsFound_Detect_PatchNumber_Tages: boolean;
 begin
      result := true;
           if not ReadCurrentPatchNumber( gLastPatchVersion) then
           begin
                MsgBox(GetMessage_CorruptedInstall, mbCriticalError, MB_OK);
                result := false;
           end
           else if  gLastPatchVersion <> GetThisPatchNumber then
           begin
                MsgBox(GetMessage_VersionMismatchPatch, mbCriticalError, MB_OK);
                result := false;
           end;
      if Result then
      begin
           gloISTages:= True;
      end;
 end;
 //------------------------------------------------------------------------------
 function InitializeSetup: boolean;
 begin
      //EugDelete_Mauvais_Groupes_Dans_StartUp;
      result := true;
      gAowPathFound := ExtractAowPath_ROK;
 
      if gAowPathFound then
      begin
           result:= AOWIsFound_Detect_PatchNumber_Tages;
      end
      else
      begin
           MsgBox(GetMessage_CorruptedInstall, mbCriticalError, MB_OK);
           result := false;
      end;
 end;