; Inno Setup file for OpenSceneGraph
; http://www.jrsoftware.org/ishelp/

#define MyCompression     "@INNO_COMPRESSION@" 
#define MyAppVersion      "@OSG_VERSION@"
#define MyAppId           "BawtOsg"
#define MyAppName         "BawtOsg @OSG_VERSION@ (@VS_VERSION@ @OSG_BITS@-bit)"
#define MyPublisher       "Paul Obermeier"
#define MyCompany         "poSoft"
#define MyAppURL          "https://www.tcl3d.org/bawt/"
#define OsgAppIcon        "Osg.ico"

[Setup]
AllowNoIcons                    = yes
AlwaysRestart                   = no
AlwaysShowComponentsList        = yes
AlwaysShowDirOnReadyPage        = yes
AlwaysShowGroupOnReadyPage      = yes
AppCopyright                    = "Copyright © @CURRENT_YEAR@ {#MyPublisher}"
AppId                           = {#MyAppId}
AppName                         = {#MyAppName}
AppVerName                      = {#MyAppName}
AppVersion                      = {#MyAppVersion} 
AppPublisher                    = {#MyCompany}
AppPublisherURL                 = {#MyAppURL}
AppSupportURL                   = {#MyAppURL}
AppUpdatesURL                   = {#MyAppURL}/download.html
ChangesEnvironment              = yes
ChangesAssociations             = yes
Compression                     = {#MyCompression}
DefaultDirName                  = {sd}\Osg
DefaultGroupName                = {#MyAppName}
DisableProgramGroupPage         = no
DisableDirPage                  = auto
InfoBeforeFile                  = "Readme-App.txt"
LicenseFile                     = "License.txt"
MinVersion                      = "6.1"
OutputBaseFilename              = "OsgSetup"
OutputDir                       = .
PrivilegesRequired              = lowest
SetupIconFile                   = {#OsgAppIcon}
UninstallDisplayIcon            = {app}\{#OsgAppIcon}
SetupLogging                    = yes
VersionInfoDescription          = {#MyAppName}
VersionInfoVersion              = {#MyAppVersion}
; 164 x 314 pixel
WizardImageFile                 = "OsgLarge.bmp"
; 55 x 58 pixel
WizardSmallImageFile            = "OsgSmall.bmp"
WizardImageStretch              = no

[Files]
Source:  "Osg\*"; \
DestDir: "{app}"; \
Flags:   recursesubdirs skipifsourcedoesntexist

Source: "Readme-App.txt"; \
DestDir: "{app}";

Source:  {#OsgAppIcon}; \
DestDir: "{app}";

Source:  "@VC_REDIST_EXE@"; \
DestDir: "{app}"; \
Flags:   skipifsourcedoesntexist

@VC_REDIST_ENABLE@[Run]
@VC_REDIST_ENABLE@Filename:    "{app}\@VC_REDIST_EXE@"; \
@VC_REDIST_ENABLE@Description: "Install VisualStudio redistributables"; \
@VC_REDIST_ENABLE@Parameters:  "/qb"; \
@VC_REDIST_ENABLE@StatusMsg:   "Installing VisualStudio redistributables"; \
@VC_REDIST_ENABLE@Flags:       postinstall skipifdoesntexist skipifsilent unchecked

[Languages]
Name:         "english"; \
MessagesFile: "compiler:Default.isl"

[Icons]
Name:         "{@SENDTO@}\osgviewer"; \
FileName:     "{app}\bin\osgviewer.exe"; \
Comment:      "Send to osgviewer"; \
Flags:        createonlyiffileexists 

Name:         "{group}\CessnaFire"; \
Filename:     "{app}\bin\osgviewer.exe"; \
Parameters:   "--window 30 30 800 600 cessnafire.osgt"; \
Comment:      "Start osgviewer with model cessnafire.osgt"; \
IconFilename: "{app}\{#OsgAppIcon}"; \
Flags:        createonlyiffileexists dontcloseonexit

Name:         "{group}\osgEarth Demo"; \
Filename:     "{app}\bin\osgearth_viewer.exe"; \
Parameters:   "--window 30 30 1000 800 readymap.earth"; \
WorkingDir:   "{app}\data\osgEarth\tests"; \
Comment:      "Start osgEarth viewer with readymap demo"; \
IconFilename: "{app}\{#OsgAppIcon}"; \
Flags:        createonlyiffileexists dontcloseonexit

Name:         "{group}\Cal3D Demo"; \
Filename:     "{app}\bin\callyDemo.exe"; \
WorkingDir:   "{app}\data\Cal3D"; \
Comment:      "Start Cal3D demo"; \
IconFilename: "{app}\{#OsgAppIcon}"; \
Flags:        createonlyiffileexists dontcloseonexit

Name:         "{group}\{cm:UninstallProgram,{#MyAppName}}"; \
Filename:     "{uninstallexe}"; \
Flags:        excludefromshowinnewinstall

;
; Tasks and Code section taken from http://legroom.net/software/modpath
;

[Tasks]
Name:         modifypath; \
Description:  Add directories to environment variable Path;

[Code]
const
    ModPathName = 'modifypath';
    ModPathType = 'user';

function ModPathDir(): TArrayOfString;
begin
    setArrayLength(Result, 2)
    Result[0] := ExpandConstant('{app}\bin');
    Result[1] := ExpandConstant('{app}\lib');
end;
#include "modpath.iss"

[Registry]
Root:      HKCU; \
Subkey:    "Environment"; \
ValueType: string; \
ValueName: "OSG_FILE_PATH"; \
ValueData: "{app}\data"; \
Flags:     uninsdeletevalue
