First working version

This commit is contained in:
Samuel Reid 2025-04-20 15:30:51 -04:00
parent a85a9709e0
commit 84e904b33b
7 changed files with 133 additions and 59 deletions

View File

@ -2,41 +2,40 @@ Function Page_DownloadContent
nsDialogs::Create 1018 nsDialogs::Create 1018
Pop $0 Pop $0
${NSD_CreateLabel} 0 0 100% 12u "Downloading required files..."
Pop $1
${NSD_CreateProgressBar} 0 14u 100% 12u ""
Pop $2
inetc::get /CAPTION "Downloading Sinfar custom content" /POPUP "Sinfar v30 Files" /QUESTION "" "https://sinfar.net/haks/sinfar_all_files_v30.7z" "$INSTPATH\sinfarFiles.7z"
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"
Pop $0 Pop $0
StrCmp $0 "OK" +2 StrCmp $0 "OK" +2
Goto download_failed 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
; Extract archive StrCmp $INSTALL_TYPE "diamond" diamond_download ee_download
;nsExec::ExecToLog '"$INSTPATH\7za.exe" x "$INSTPATH\sinfarFiles.7z" -o"$INSTPATH" -y'
; Delete "$INSTPATH\sinfarFiles.7z" diamond_download:
; Delete "$INSTPATH\7za.exe" 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:
${NSD_CreateLabel} 0 0 100% 12u "Ready to install Sinfar for Neverwinter Nights : $INSTALL_TYPE"
Pop $1
nsDialogs::Show nsDialogs::Show
Goto done Goto done
download_failed: download_failed:
MessageBox MB_ICONSTOP "Download failed or was canceled." MessageBox MB_ICONSTOP "Download failed or was cancelled. Install process will stop."
Abort Abort
done: done:

View File

@ -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

View File

@ -4,6 +4,9 @@
Var PathTextBoxHandle Var PathTextBoxHandle
Function Page_SelectNWNPath Function Page_SelectNWNPath
StrCpy $INSTPATH "C:\Program Files (x86)\GOG Galaxy\Games\NWN Diamond"
nsDialogs::Create 1018 nsDialogs::Create 1018
Pop $0 Pop $0

View File

@ -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

View File

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 220 KiB

55
main.nsi Normal file
View File

@ -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

View File

@ -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