From 6b7be66afd8fa922685619658353be36adc92395 Mon Sep 17 00:00:00 2001 From: Fiery Imp Date: Sun, 20 Apr 2025 15:30:51 -0400 Subject: [PATCH] First working version --- Pages/page_download_files.nsi | 47 ++++++++------- Pages/page_game_selection.nsi | 38 ++++++++++++ Pages/page_select_path.nsi | 3 + Sections/section_extract_files.nsi | 14 +++++ .../installerico.ico | Bin main.nsi | 55 ++++++++++++++++++ sinfarInstaller.nsi | 35 ----------- 7 files changed, 133 insertions(+), 59 deletions(-) create mode 100644 Pages/page_game_selection.nsi create mode 100644 Sections/section_extract_files.nsi rename installerico.ico => UIContent/installerico.ico (100%) create mode 100644 main.nsi delete mode 100644 sinfarInstaller.nsi diff --git a/Pages/page_download_files.nsi b/Pages/page_download_files.nsi index cdc0bcd..f860db5 100644 --- a/Pages/page_download_files.nsi +++ b/Pages/page_download_files.nsi @@ -2,41 +2,40 @@ Function Page_DownloadContent nsDialogs::Create 1018 Pop $0 - ${NSD_CreateLabel} 0 0 100% 12u "Downloading required files..." - Pop $1 - - ${NSD_CreateProgressBar} 0 14u 100% 12u "" - Pop $2 - - MessageBox MB_OK "Saving to: $INSTPATH\sinfarFiles.7z" - ; Real progress bar download using inetc plugin - inetc::get /CAPTION "Downloading files..." /RESUME /POPUP "" /NOCANCEL \ - /FILE "$INSTPATH\sinfarFiles.7z" \ - "https://sinfar.net/haks/sinfar_all_files_v30.7z" - + inetc::get /CAPTION "Downloading Sinfar custom content" /POPUP "Sinfar v30 Files" /QUESTION "" "https://sinfar.net/haks/sinfar_all_files_v30.7z" "$INSTPATH\sinfarFiles.7z" Pop $0 StrCmp $0 "OK" +2 Goto download_failed - ; Download the 7za executable (or bundle it inside installer — up to you) - ;NSISdl::download "https://your.url/7za.exe" "$INSTPATH\7za.exe" - ;Pop $0 - ;StrCmp $0 "cancel" download_failed + + StrCmp $INSTALL_TYPE "diamond" diamond_download ee_download + +diamond_download: + inetc::get /CAPTION "Downloading Sinfar Diamond Launcher" /POPUP "Sinfarx launcher" /QUESTION "" "https://nwn.sinfar.net/files/sinfarx.exe" "$INSTPATH\sinfarx.exe" + Pop $0 + StrCmp $0 "OK" +2 + Goto download_failed + + Goto after_download + +ee_download: + inetc::get /CAPTION "Downloading Sinfar EE Launcher" /POPUP "Sinfarx launcher" /QUESTION "" "https://nwn.sinfar.net/files/sinfarx_ee.exe" "$INSTPATH\sinfarx.exe" + Pop $0 + StrCmp $0 "OK" +2 + Goto download_failed + +after_download: - ; Extract archive - ;nsExec::ExecToLog '"$INSTPATH\7za.exe" x "$INSTPATH\sinfarFiles.7z" -o"$INSTPATH" -y' - - ; Delete "$INSTPATH\sinfarFiles.7z" - ; Delete "$INSTPATH\7za.exe" - - nsDialogs::Show + ${NSD_CreateLabel} 0 0 100% 12u "Ready to install Sinfar for Neverwinter Nights : $INSTALL_TYPE" + Pop $1 + nsDialogs::Show Goto done download_failed: - MessageBox MB_ICONSTOP "Download failed or was canceled." + MessageBox MB_ICONSTOP "Download failed or was cancelled. Install process will stop." Abort done: diff --git a/Pages/page_game_selection.nsi b/Pages/page_game_selection.nsi new file mode 100644 index 0000000..b29c3f5 --- /dev/null +++ b/Pages/page_game_selection.nsi @@ -0,0 +1,38 @@ +!include "nsDialogs.nsh" + +Var InstallTypeRadio_NWNDIAMOND +Var InstallTypeRadio_NWNEE + +Function Page_GameSelection + nsDialogs::Create 1018 + Pop $0 + + ${NSD_CreateLabel} 0 0 100% 12u "Select your game's version:" + Pop $1 + + ${NSD_CreateRadioButton} 0 20u 100% 10u "Neverwinter Nights Diamond Edition" + Pop $InstallTypeRadio_NWNDIAMOND + +; ${NSD_CreateRadioButton} 0 32u 100% 10u "Neverwinter Nights: Enhanced Edition" +; Pop $InstallTypeRadio_NWNEE + + ${NSD_SetState} $InstallTypeRadio_NWNDIAMOND ${BST_CHECKED} + + nsDialogs::Show +FunctionEnd + +Function Page_GameSelection_Validation + ${NSD_GetState} $InstallTypeRadio_NWNDIAMOND $0 + StrCmp $0 ${BST_CHECKED} 0 +3 + StrCpy $INSTALL_TYPE "Diamond" + Goto end + + StrCpy $INSTALL_TYPE "EE" + +end: + DetailPrint "Game version: $INSTALL_TYPE" +FunctionEnd + + +; C:\Program Files (x86)\GOG Galaxy\Games\NWN Diamond +; C:\Program Files (x86)\GOG Galaxy\Games\Neverwinter Nights Enhanced Edition \ No newline at end of file diff --git a/Pages/page_select_path.nsi b/Pages/page_select_path.nsi index dd5306b..30462aa 100644 --- a/Pages/page_select_path.nsi +++ b/Pages/page_select_path.nsi @@ -4,6 +4,9 @@ Var PathTextBoxHandle Function Page_SelectNWNPath + + StrCpy $INSTPATH "C:\Program Files (x86)\GOG Galaxy\Games\NWN Diamond" + nsDialogs::Create 1018 Pop $0 diff --git a/Sections/section_extract_files.nsi b/Sections/section_extract_files.nsi new file mode 100644 index 0000000..9a97a26 --- /dev/null +++ b/Sections/section_extract_files.nsi @@ -0,0 +1,14 @@ + +; The stuff to install +Section "Installing" ;No components page, name is not important + SetOutPath $INSTPATH + DetailPrint "Extracting package..." + + Nsis7z::ExtractWithDetails "$INSTPATH\sinfarFiles.7z" "Installing package %s..." + + DetailPrint "Extraction complete." + + DetailPrint "Deleting temporary files." + ; Delete "$INSTPATH\sinfarFiles.7z" +SectionEnd ; end the section + diff --git a/installerico.ico b/UIContent/installerico.ico similarity index 100% rename from installerico.ico rename to UIContent/installerico.ico diff --git a/main.nsi b/main.nsi new file mode 100644 index 0000000..1ad8159 --- /dev/null +++ b/main.nsi @@ -0,0 +1,55 @@ +;!include "MUI2.nsh" +!include "nsDialogs.nsh" +!include "LogicLib.nsh" + +Outfile "SinfarInstaller-v30.exe" ; Name of the output file +RequestExecutionLevel admin ; We need admin right just to be sure everything work smoothly, use can refuse anyway. +Icon "UIContent\installerico.ico" ; Sinfar icon!!! + + + +InstallDir "$PROGRAMFILES\DummyInstall" + +Var INSTALL_TYPE +Var INSTPATH + +;Pages +!include "Pages\page_select_path.nsi" +!include "Pages\page_download_files.nsi" +!include "Pages\page_game_selection.nsi" +;Sections +!include "Sections\section_extract_files.nsi" + +Page custom Page_GameSelection Page_GameSelection_Validation ; Game selection, ee vs diamond +Page custom Page_SelectNWNPath Page_SelectNWNPath_Validation ; Custom page first +Page custom Page_DownloadContent "" ; Download page +Page InstFiles ; Then show Install progress + +Function .onInit + SetDetailsView show ; ensure log is visible + DetailPrint "===============================" + DetailPrint "Sinfar Installer v30" + DetailPrint "===============================" + DetailPrint "Initializing..." +FunctionEnd + +Section "Create Shortcut" + DetailPrint "Creating desktop shortcut." + File "UIContent\installerico.ico" + + ; Path to the target file + StrCpy $0 "$INSTPATH\sinfarx.exe" + + ; Path to the desktop shortcut + StrCpy $1 "$DESKTOP\Sinfar.lnk" + + ; Create the shortcut + CreateShortcut "$1" "$0" "$INSTDIR\installerico.ico" + +SectionEnd + +Section "Done" + DetailPrint "Installation done, launch game from the desktop shortcut to start playing." +SectionEnd + + diff --git a/sinfarInstaller.nsi b/sinfarInstaller.nsi deleted file mode 100644 index 72b0377..0000000 --- a/sinfarInstaller.nsi +++ /dev/null @@ -1,35 +0,0 @@ -;!include "MUI2.nsh" -!include "nsDialogs.nsh" -!include "LogicLib.nsh" - - - -Outfile "SinfarInstaller-v30.exe" ; Name of the output file -RequestExecutionLevel admin ; We need admin right just to be sure everything work smoothly, use can refuse anyway. -Icon "installerico.ico" ; Sinfar icon!!! - -InstallDir "$PROGRAMFILES\DummyInstall" - -Var INSTPATH - - -!include "Pages\page_select_path.nsi" -!include "Pages\page_download_files.nsi" - -Page custom Page_SelectNWNPath Page_SelectNWNPath_Validation ; Custom page first -Page custom Page_DownloadContent "" ; Download page -Page InstFiles ; Then show Install progress - - - -Section "Install Dummy Files" SEC01 - - ; Create the install directory - SetOutPath "$INSTDIR" - - ; Write a simple Hello World text file - FileOpen $0 "$INSTDIR\hello.txt" w - FileWrite $0 "Hello World!" - FileClose $0 - -SectionEnd \ No newline at end of file