﻿; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Superpaper"
; #define MyAppVersion "null"  ; Set version via a command line argument
#define MyAppPublisher "Henri Hänninen"
#define MyAppURL "https://github.com/hhannine/superpaper/"
#define MyAppExeName "superpaper.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{3E097BBB-045C-4E42-AF0C-918C5AB359BB}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile=..\LICENSE
; Uncomment the following line to run in non administrative install mode (install for current user only.)
PrivilegesRequired=admin
;PrivilegesRequiredOverridesAllowed=dialog
OutputDir=..\releases\{#MyAppVersion}
OutputBaseFilename=superpaper_win_installer
SetupIconFile=..\superpaper\resources\superpaper.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern

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

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "startupicon"; Description: "Start application with Windows"; GroupDescription: "{cm:AdditionalIcons}"

[Files]
Source: "..\dist\superpaper.exe"; DestDir: "{app}\superpaper"; Flags: ignoreversion
Source: "..\releases\innostub\profiles\*"; DestDir: "{app}\superpaper\profiles"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "..\releases\innostub\superpaper\*"; DestDir: "{app}\superpaper"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\superpaper\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\superpaper\{#MyAppExeName}"; Tasks: desktopicon
;Name: "{userstartup}\{#MyAppName}"; Filename: "{app}\superpaper\{#MyAppExeName}"; Tasks: startupicon
;Name: "{userstartup}\{#MyAppName}"; Filename: "{app}\superpaper\{#MyAppExeName}"  ; system-wide startup

[Registry]
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "{#MyAppName}"; ValueData: """{app}\superpaper\{#MyAppExeName}"""; Flags: uninsdeletevalue; Tasks: startupicon

[Run]
Filename: "{app}\superpaper\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[Code]
 procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);
 var
     mres : integer;
 begin
    case CurUninstallStep of                   
      usPostUninstall:
        begin
          mres := MsgBox('Do you want to Remove all settings and profiles?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
          if mres = IDYES then
            DelTree(ExpandConstant('{localappdata}\Superpaper'), True, True, True);
       end;
   end;
end;
