Porządne tutoriale do NSISa

0

Witam Bracia i Siostry w kodzie

Czy ktoś z Was zna jakieś naprawdę porządne, esencjonalne, takie od dechy do dechy tutoriale do NSISa, ewentualnie wie jak robić w tym instalatory? Gógluję od paru godzin, ale znajduję jedynie albo jakieś Hello Wordy z jednym message boxem, albo coś wyrąbanego w kosmos co dla zielonego w temacie jest kompletnie niestrawne, natomiast nie natrafiłem na nic co do Peruna miałoby wszystko po kolei opisane jak Swaróg przykazał:

  • strona 'Welcome', i wyjaśnienie co i jak tam na niej sobie pokazać
  • strona license, i j.w.
  • strona wyboru folderu instalacyjnego
  • strona wyboru komponentów do instalacji
  • instalowanie
  • deinstalator
  • skróty w menu start i na pulpicie

Trochę poratowałem się wizardem NSIS Quick Setup Script Generator, ale to co wyrzucił nie jest niestety do końca tym co bym potrzebował (brakuje możliwości wyboru komponentów).

Poratujcie Bracia!
(@kq - przerzuć proszę we właściwe miejsce forum)

1

Skrypt: https://gist.github.com/vpiotr/e6b64861c32fa25f1b5c3d37cc86265f

Jakby coś było niejasne to pytaj, ale ostrzegam że to skrypt z 2011 roku.

2

Miałem klika podejść do NSIS i jakoś nie mogłem się przesiąść, kiedyś używałem Bytessence InstallMaker (BIM) ale padło i szukałem alternatywy, wtedy rozkminiałem co wybrać i po researchu zostały mi dwa: NSIS i Inno Setup , wybrałem Inno Setuo, wraz z Inno Script Studio pozwala w łatwy sposób stworzyć prostego instalatora bez zagłębiania się w meandry dokumentacji,

Nie pomogłem, ale jak czytam post to widzę że jesteś na początku drogi więc zmiana nie powinna być bolesna.

0

@Panczo:
Faktycznie, ten Inno Setup wydaje się dużo przyjaźniejszy, niestety, instalator jakiego potrzebuję nie należy do prostych :/ Oto co ma robić:

  1. Pokazać stronę powitalną //to poszło
  2. Pokazać licencję //to też
  3. Zapytać się o ścieżkę instalacji //i to również
  4. Zapytać się o ścieżkę do battletech.exe -> $BattletechFolder //tego niestety nie umiem :/
  5. Wyświetlić listę komponentów do zainstalowania: //uznajmy, że jakoś tam się udało. Niestety, własne [TYPES] nie działają, ale walić to
  • Mech Designer core
  • Flashpoint mechs pack //tutaj może sprawdzać np czy w /data jest folder /flashpoint, jak nie znajdzie to dać komponent jako nieaktywny?
    • Uwaga!!! jeśli lokacje /chassisdef oraz /mechdef zawierają tak nazwane .jsony to zapytać o nadpisanie!
  1. Skopiować pliki do INSTALDIR// a komponent Flashpoint mechs pack do odpowiednich podfolderów $BattletechFolder. Generalnie poszło poza uwarunkowaniem typem komponentu
  2. Opcjonalnie powiązać pliki .mechDesign z aplikacją Mech Designer //tylko dla komponentu core
  3. Zapytać się o utworzenie grupy w menu Start, oraz ikony na pulpicie //tylko dla komponentu core. Generalnie poszło poza uwarunkowaniem typem komponentu
  4. Utworzyć deinstalator, przy czym UWAGA! Jeśli był instalowany wyłącznie komponent "Flashpoint mechs" wtedy ma nie tworzyć. Generalnie poszło poza uwarunkowaniem typem komponentu
  5. Zakończyć instalację
2
  1. Zapytać się o ścieżkę do battletech.exe -> $BattletechFolder //tego niestety nie umiem :/

http://www.vincenzo.net/isxkb/index.php?title=Prompt_for_an_additional_folder_for_data

  1. Wyświetlić listę komponentów do zainstalowania: //uznajmy, że jakoś tam się udało. Niestety, własne [TYPES] nie działają, ale walić to

To dewiniujesz w sekcji TYPES http://www.jrsoftware.org/ishelp/index.php?topic=typessection, jeżeli ustawisz, flagę iscustom wtedy instalator przejdzie do wyboru komponentów http://www.jrsoftware.org/ishelp/topic_componentssection.htm

Lub ustawić w skrypcie AlwaysShowComponentsList na Yes i wtedy zawsze będzie lista komponentów do wybrania

  • Flashpoint mechs pack //tutaj może sprawdzać np czy w /data jest folder /flashpoint, jak nie znajdzie to dać komponent jako nieaktywny?

Mozna tak: https://stackoverflow.com/questions/10283508/how-to-allow-to-only-install-specific-components-in-innosetup
Zamiast na sztywno pisać false użyć wbudowanej funkcji DirExists(DirName);

  • Uwaga!!! jeśli lokacje /chassisdef oraz /mechdef zawierają tak nazwane .jsony to zapytać o nadpisanie!

To możesz ustawić flagą confirmoverwrite w sekcji files http://www.jrsoftware.org/ishelp/index.php?topic=filessection

  1. Skopiować pliki do INSTALDIR// a komponent Flashpoint mechs pack do odpowiednich podfolderów $BattletechFolder. Generalnie poszło poza uwarunkowaniem typem komponentu

z pierwszego linku:

[Files]
;Main program that will be installed in {app} folder
Source: MyProg.exe; DestDir: {app}

;Database file that will installed where user choosed
Source: DataBase.mdb; DestDir: {code:GetDataDir}\nazwapodfolderu

  1. Opcjonalnie powiązać pliki .mechDesign z aplikacją Mech Designer //tylko dla komponentu core

http://www.jrsoftware.org/isfaq.php#assoc i we wpisać registy dodać Components: core

  1. Zapytać się o utworzenie grupy w menu Start, oraz ikony na pulpicie //tylko dla komponentu core. Generalnie poszło poza uwarunkowaniem typem komponentu

Tworzysz taska:

[Icons]
Name: "{userdesktop}\program"; Filename: "{app}\start.exe"; IconFilename: "{app}\pulpitikona.ico"; Components: core; Tasks: desktopicon\user
Name: "{commondesktop}\progr"; Filename: "{app}\start.exe"; IconFilename: "{app}\pulpitikona.ico"; Components: core; Tasks: desktopicon\common


[Tasks]
;Ikony pulpit
Name: desktopicon; Description: "Czy utworzyć skrót na pulpicie"; GroupDescription: "Skróty na pulpicie:"; Components: core
Name: desktopicon\common; Description: "Dla wszystkich użytkowników"; GroupDescription: "Skróty na pulpicie:"; Components: core; Flags: exclusive
Name: desktopicon\user; Description: "Tylko dla bieżącego użytkownika"; GroupDescription: "Skróty na pulpicie:"; Components: core; Flags: exclusive unchecked
  1. Utworzyć deinstalator, przy czym UWAGA! Jeśli był instalowany wyłącznie komponent "Flashpoint mechs" wtedy ma nie tworzyć. Generalnie poszło poza uwarunkowaniem typem komponentu

Deinstalator sie tworzy sam, to wynika z opcji które zaznaczasz i zależne jest od falg odpowiedzialnych za odinstalowanie

  1. Zakończyć instalację
0

Kude, ratuj Bracie @Panczo! znienacka zniknęło mi pytanie się o ścieżkę do instalacji :/ po prostu tej strony nie ma.

EDIT:
Ale ze mnie <tu wstaw wyrażenie>...nie odinstalowałem poprzedniej instancji, więc z automatu chciał robić aktualizację do poprzedniej lokacji, i stąd o ścieżkę nie pytał. Fałszywy alarm.

0

Hmm...z tymi komponentami to mi nie wychodzi Bracie @Panczo. Działa jak zdefiniuję tak:

[Components]
Name: "MechDesigner"; Description: "Mech Designer core files"; Types: full custom
Name: "FlashpointPack"; Description: "Flashpoint mechs pack"; Types: full compact custom

ale już przy takim układzie nie pokazuje komponentów, i nawet AlwaysShowComponentsList nie pomaga:

[Types]
Name "Core"; Description "Mech Designer required files";
Name "Flashpoint"; Description "Flashpoint mechs data files"

[Components]
Name: "MechDesigner"; Description: "Mech Designer core files"; Types: Core
Name: "FlashpointPack"; Description: "Flashpoint mechs pack"; Types: Core Flashpoint
2

masz błąd w sekcji TYPES brakuje ci :, aby pokazać komponenty jeden musi mieć flagę iscustom:

[Setup]
AppName=4p
AppVersion=1
AlwaysShowComponentsList=yes
DefaultDirName={pf}\4p

[Types]
Name: "Core"; Description: "Mech Designer required files"; Flags: iscustom
Name: "Flashpoint"; Description: "Flashpoint mechs data files"

[Components]
Name: "MechDesigner"; Description: "Mech Designer core files"; Types: Core
Name: "FlashpointPack"; Description: "Flashpoint mechs pack"; Types: Core Flashpoint

0

A jeślibym chciał użyć

function GetOpenFileName(const Prompt: String; var FileName: String; const InitialDirectory, Filter, DefaultExtension: String): Boolean;

do znalezienia tej potrzebnej mi ścieżki dla plików z mech packa, to jak to zrobić @Panczo? Pewnie należałoby zdefiniować sobie jakąś zmienną, podobną do tych {sd} albo {pf}, i do niej zwrócić rezultat wywołania GetOpenFileName.

2

Przetestuj:

[Setup]
AppName=4p
AppVersion=1
AlwaysShowComponentsList=yes
DefaultDirName={pf}\4p

[Types]
Name: "Core"; Description: "Mech Designer required files"; Flags: iscustom
Name: "Flashpoint"; Description: "Flashpoint mechs data files"

[Components]
Name: "MechDesigner"; Description: "Mech Designer core files"; Types: Core
Name: "FlashpointPack"; Description: "Flashpoint mechs pack"; Types: Core Flashpoint

[Code]
var
  battletechPage: TInputFileWizardPage;
procedure InitializeWizard;
begin
  battletechPage := CreateInputFilePage(wpSelectDir, 'battletech.exe', 'Wskaż ścieżkę do pliku battletech.exe',
    'Opis na formularzu');
  battletechPage.Add('battletech.exe', 'battletech.exe|battletech.exe', '.exe');
end;

procedure RegisterPreviousData(PreviousDataKey: Integer);
begin
  // Store the selected folder for further reinstall/upgrade
  SetPreviousData(PreviousDataKey, 'battletechfile', battletechPage.Values[0]);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
if CurPageID = battletechPage.ID then
  begin
    if battletechPage.Values[0] = '' then
     begin
      MsgBox('Plik musi zostać wybrany!', mbInformation, MB_OK);
      Result := False;
      end
     else
      begin
         //KOD JAK JEST OK
         msgbox(ExtractFileDir(battletechPage.Values[0]), mbInformation, MB_OK);
      End;
  end;
end;

function battletechDir(Param: String): String;
begin
  { Return the selected DataDir }
  Result := ExtractFileDir(battletechPage.Values[0]);
end;

Odwołujesz się do folderu przez {code:battletechDir}

0

Olbrzymie dzięki Bracie @Panczo, to niemal to czego potrzebuję. Na własną rękę próbowałem dorobić sprawdzanie poprawności wybranej ścieżki, niestety nie do końca wyszło :/ Ponadto nie dostrzegam sposobu aby tą stronę wizarda instalacyjnego wyświetlać po wyborze komponentów pod warunkiem, że do instalacji wybrano Flashpoint mech pack.
Oto co mam:

[Setup]
AppName=4p
AppVersion=1
AlwaysShowComponentsList=yes
DefaultDirName={sd}\4p

[Types]
Name: "Core"; Description: "Mech Designer required files"; Flags: iscustom
Name: "Flashpoint"; Description: "Flashpoint mechs data files"

[Components]
Name: "MechDesigner"; Description: "Mech Designer core files"; Types: Core
Name: "FlashpointPack"; Description: "Flashpoint mechs pack"; Types: Core Flashpoint

[Code]
var
  battletechPage: TInputFileWizardPage;
procedure InitializeWizard;
begin
  battletechPage := CreateInputFilePage(wpSelectDir, 'Mech pack requires additional path leading to battletech.exe', '', 'Navigate to and point the battletech.exe from expansion');
  battletechPage.Add('Path to battletech.exe', 'battletech.exe|battletech.exe', '.exe');
end;

procedure RegisterPreviousData(PreviousDataKey: Integer);
begin
  // Store the selected folder for further reinstall/upgrade
  SetPreviousData(PreviousDataKey, 'battletechfile', battletechPage.Values[0]);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
  if CurPageID = battletechPage.ID then
  begin
    if battletechPage.Values[0] = '' then
    begin
      MsgBox('You have to select the battletech.exe!', mbInformation, MB_OK);
      Result := False;
    end
    else
    begin
      //KOD JAK JEST OK
      msgbox(ExtractFileDir(battletechPage.Values[0]), mbInformation, MB_OK);
      //oto co ja dodałem. Zaraz odpalę gógle aby znaleźć "pascal string concatenation"
      //hmmm no niby twierdzą w https://www.freepascal.org/docs-html/rtl/system/concat.html, że operator + działa, to czemu nie wykrywa warunku??
      if not DirExists(battletechPage.Values[0] + '\BattleTech_Data\StreamingAssets\data\flashpoints') then        
      begin
          msgbox('Wrong path! You have to navigare to Flashpoint main folder!', mbInformation, MB_OK);
          Result := false;
         //tu sprawdzenie czy w dobre miejsce użytkownik pokierował
      end;
    end;
  end;
end;

function battletechDir(Param: String): String;
begin
  { Return the selected DataDir }
  Result := ExtractFileDir(battletechPage.Values[0]);
end;
2

Wykorzystaj funkcje ShouldSkipPage i zależnie od zaznaczonego komponentu wyświetl.
Kolejność kiedy ma byc wyświetlana strona zalezy od pierwszego argumenu funkcji CreateInputFilePage teraz wyswietli się po komponentach.

Masz błąd w linijce:

if not DirExists(battletechPage.Values[0] + '\BattleTech_Data\StreamingAssets\data\flashpoints') then

Warośc battletechPage.Values[0] to ścieżka razem z plikiem więc sprawdzasz taki katalog:

c:\folder\battletech.exe\BattleTech_Data\StreamingAssets\data\flashpoints więc raczej cięzko aby istniała użyj ExtractFileDir(battletechPage.Values[0])

 [Setup]
 AppName=4p
 AppVersion=1
 AlwaysShowComponentsList=yes
 DefaultDirName={sd}\4p
 
 [Types]
 Name: "Core"; Description: "Mech Designer required files"; Flags: iscustom
 Name: "Flashpoint"; Description: "Flashpoint mechs data files"
 
 [Components]
 Name: "MechDesigner"; Description: "Mech Designer core files"; Types: Core
 Name: "FlashpointPack"; Description: "Flashpoint mechs pack"; Types: Core Flashpoint
 
 [Code]
 var
   battletechPage: TInputFileWizardPage;
   battletechPageID: Integer;
 procedure InitializeWizard;
 begin
   battletechPage := CreateInputFilePage(wpSelectTasks, 'Mech pack requires additional path leading to battletech.exe', '', 'Navigate to and point the battletech.exe from expansion');
   battletechPage.Add('Path to battletech.exe', 'battletech.exe|battletech.exe', '.exe');
   battletechPageID := battletechPage.ID;
 end;
 
 procedure RegisterPreviousData(PreviousDataKey: Integer);
 begin
   // Store the selected folder for further reinstall/upgrade
   SetPreviousData(PreviousDataKey, 'battletechfile', battletechPage.Values[0]);
 end;
 
 function NextButtonClick(CurPageID: Integer): Boolean;
 begin
   Result := True;
   if CurPageID = battletechPageID then
   begin
     if battletechPage.Values[0] = '' then
     begin
       MsgBox('You have to select the battletech.exe!', mbInformation, MB_OK);
       Result := False;
     end
     else
     begin
       //KOD JAK JEST OK
       msgbox(ExtractFileDir(battletechPage.Values[0]), mbInformation, MB_OK);
       //oto co ja dodałem. Zaraz odpalę gógle aby znaleźć "pascal string concatenation"
       //hmmm no niby twierdzą w https://www.freepascal.org/docs-html/rtl/system/concat.html, że operator + działa, to czemu nie wykrywa warunku??
       if not DirExists(ExtractFileDir(battletechPage.Values[0]) + '\BattleTech_Data\StreamingAssets\data\flashpoints') then        
       begin
           msgbox('Wrong path! You have to navigare to Flashpoint main folder!', mbInformation, MB_OK);
           Result := false;
          //tu sprawdzenie czy w dobre miejsce użytkownik pokierował
       end;
     end;
   end;
 end;
 
 function battletechDir(Param: String): String;
 begin
   { Return the selected DataDir }
   Result := ExtractFileDir(battletechPage.Values[0]);
 end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result := False;
  if PageID = battletechPageID then
    Result := not IsComponentSelected('FlashpointPack');
end;
0

DZIAŁA! Olbrzymie dzięki, teraz dospawam to do swojego głównego pliku. Miałeś rację Bracie Paczo, NSIS nawet się nie umywa do prostoty i przyjazności Inno Setup. Inno Script Studio też jest dobre.

0

Ja bym powiedział, że inno bardziej mi podpasowal. Nie mam jakiegoś szczególnego porównania obu, bo wiem że w NSIS też byś to osiągnął. Inno ułatwił mi start i dzięki temu z nim zostałem. Zresztą jak często pisze się instalatory, sam musiałem sobie sporo odświeżyć odpowiadając na Twoje pytania.
Pewnie jakbyś trafił na tym forum na kogoś kto zna NSISa to by Cię pokierował tak samo jak ja Ciebie

0

No ale nie trafiłem na takowego speca od NSISa. Okkay, jest wstępna wersja działająca jak chcę (tylko jeszcze tego powiązania nie robi, ale to potem sam dospawam), zatem Bracie Panczo nie tylko dostaniesz słusznie należnego ptaszka, ale i @cerrato zawołam aby postawił łapkę przy każdym Twoim poście, bo zasługują na więcej niż jedną.

A dla potomnych kod:

[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={{CD963CF4-FE83-434A-B3FA-67BB45338268}
AppName=Mech Designer
AppVersion=0.7
;AppVerName=Mech Designer 0.7
AppPublisher=MasterBLB's Soft
DefaultDirName={sd}\Mech Designer by MasterBLB
DefaultGroupName=Mech Designer by MasterBLB
AllowNoIcons=yes
LicenseFile=C:\Qt\Projects\MechDesigner\Documentation\license.txt
Compression=lzma
SolidCompression=yes
DisableWelcomePage=False
AllowRootDirectory=False
ShowLanguageDialog=yes
AlwaysShowComponentsList=yes
OutputBaseFilename=MechDesignerInstaller
OutputDir=C:\Qt\Projects\MechDesigner\Installer
;if only a mech pack is installed don't create uninstaller
Uninstallable=WizardIsComponentSelected('MechDesigner')

[Types]
Name: "Core"; Description: "Full installation"
Name: "Flashpoint"; Description: "Only Flashpoint mechs data files"
Name: "Custom"; Description: "Custom installation"; Flags: iscustom

[Components]
Name: "MechDesigner"; Description: "Mech Designer core files"; Types: Core Custom
Name: "FlashpointPack"; Description: "Flashpoint mechs pack"; Types: Core Flashpoint Custom

[Files]
Source: "C:\Qt\Projects\MechDesigner\Installer\Data\MechDesigner.exe"; DestDir: "{app}"; Components: MechDesigner
Source: "C:\Qt\Projects\MechDesigner\Installer\Data\setup.ini"; DestDir: "{app}"; Components: MechDesigner; Flags: onlyifdoesntexist
Source: "..\Documentation\Mech Designer user's manual.pdf"; DestDir: "{app}"; Components: MechDesigner; Flags: isreadme
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
Source: "Data\libgcc_s_dw2-1.dll"; DestDir: "{app}"; Components: MechDesigner
Source: "Data\libstdc++-6.dll"; DestDir: "{app}"; Components: MechDesigner
Source: "Data\libwinpthread-1.dll"; DestDir: "{app}"; Components: MechDesigner
Source: "Data\Qt5Core.dll"; DestDir: "{app}"; Components: MechDesigner
Source: "Data\Qt5Gui.dll"; DestDir: "{app}"; Components: MechDesigner
Source: "Data\Qt5Widgets.dll"; DestDir: "{app}"; Components: MechDesigner
Source: "Data\GUI\Actuators.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\Ammo.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\BallisticHardpoint.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\CloseButton.PNG"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\CockpitMods.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\Computers.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\DockedMode.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\EnergyHardpoint.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\FloatingMode.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\Gyro.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\HeatDissipated.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\HeatGenerated.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\Heatsinks.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\JumpJets.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\MissileHardpoint.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\Slots.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\SupportHardpoint.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\Tonnage.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\GUI\Warning.png"; DestDir: "{app}\GUI"; Components: MechDesigner
Source: "Data\platforms\qwindows.dll"; DestDir: "{app}\platforms"; Components: MechDesigner
Source: "Data\styles\qwindowsvistastyle.dll"; DestDir: "{app}\styles"; Components: MechDesigner

;Flashpoint mechs data
Source: "Data\Flashpoint mechs\chassisdef_crab__fp_gladiator_BSC-27.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Data\Flashpoint mechs\mechdef_crab__fp_gladiator_BSC-27.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Data\Flashpoint mechs\chassisdef_crab_CRB-27.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Data\Flashpoint mechs\mechdef_crab_CRB-27.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Data\Flashpoint mechs\chassisdef_cyclops_CP-10-Q.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Data\Flashpoint mechs\mechdef_cyclops_CP-10-Q.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Data\Flashpoint mechs\chassisdef_cyclops_CP-10-Z.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Data\Flashpoint mechs\mechdef_cyclops_CP-10-Z.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Data\Flashpoint mechs\chassisdef_hatchetman_HCT-3F.json"; DestDir: "{code:battletechDataDir}\chassis"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack
Source: "Data\Flashpoint mechs\mechdef_hatchetman_HCT-3F.json"; DestDir: "{code:battletechDataDir}\mech"; Flags: uninsneveruninstall confirmoverwrite; Components: FlashpointPack

[Icons]
Name: "{group}\Mech Designer"; Filename: "{app}\MechDesigner.exe"; Components: MechDesigner
Name: "{group}\Mech Designer user's manual"; Filename: "{app}\Mech Designer user's manual.pdf"; Components: MechDesigner
Name: "{group}\{cm:UninstallProgram,Mech Designer}"; Filename: "{uninstallexe}"; Components: MechDesigner
Name: "{commondesktop}\Mech Designer"; Filename: "{app}\MechDesigner.exe"; Tasks: desktopicon; Components: MechDesigner

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Components: MechDesigner

[Run]
Filename: "{app}\MechDesigner.exe"; Description: "{cm:LaunchProgram,Mech Designer}"; Flags: nowait postinstall skipifsilent; Components: MechDesigner

[Code]
var
  battletechPage: TInputFileWizardPage;
  battletechPageID: Integer;
  
function battletechDataDir(Param: String): String;
begin
  //Return the selected DataDir - it removes battletech.exe from the path, and returns the rest
  Result := ExtractFileDir(battletechPage.Values[0]) + '\BattleTech_Data\StreamingAssets\data';
end;  

procedure InitializeWizard;
begin
  battletechPage := CreateInputFilePage(wpSelectTasks, 'Flashpoint mech pack requires additional path which leads to proper battletech.exe', '', 'Navigate to and point the battletech.exe from expansion');
  battletechPage.Add('Path to battletech.exe', 'battletech.exe|battletech.exe', '.exe');
  battletechPageID := battletechPage.ID;
end;

procedure RegisterPreviousData(PreviousDataKey: Integer);
begin
  // Store the selected folder for further reinstall/upgrade
  SetPreviousData(PreviousDataKey, 'battletechfile', battletechPage.Values[0]);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
  if CurPageID = battletechPageID then
  begin
    if battletechPage.Values[0] = '' then
    begin
      MsgBox('You have to select the battletech.exe!', mbInformation, MB_OK);
      Result := False;
    end
    else
    begin
      //check if user selected right directory
      if not DirExists(ExtractFileDir(battletechPage.Values[0]) + '\BattleTech_Data\StreamingAssets\data\flashpoints') then        
      begin
        msgbox('Wrong path! You have to navigare to Battletech Flashpoint main folder!', mbInformation, MB_OK);
        Result := false;
      end;
    end;
  end;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result := False;
  if PageID = battletechPageID then Result := not IsComponentSelected('FlashpointPack');
end;

1 użytkowników online, w tym zalogowanych: 0, gości: 1