commit 81772d3217746d764a6a9b08f7a3e1d1057fe83c Author: Samuel Reid Date: Sun Apr 20 08:56:39 2025 -0400 Initial Commit WIP diff --git a/Pages/page_download_files.nsi b/Pages/page_download_files.nsi new file mode 100644 index 0000000..cdc0bcd --- /dev/null +++ b/Pages/page_download_files.nsi @@ -0,0 +1,43 @@ +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" + + 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 + + ; Extract archive + ;nsExec::ExecToLog '"$INSTPATH\7za.exe" x "$INSTPATH\sinfarFiles.7z" -o"$INSTPATH" -y' + + ; Delete "$INSTPATH\sinfarFiles.7z" + ; Delete "$INSTPATH\7za.exe" + + nsDialogs::Show + + Goto done + +download_failed: + MessageBox MB_ICONSTOP "Download failed or was canceled." + Abort + +done: +FunctionEnd \ No newline at end of file diff --git a/Pages/page_select_path.nsi b/Pages/page_select_path.nsi new file mode 100644 index 0000000..dd5306b --- /dev/null +++ b/Pages/page_select_path.nsi @@ -0,0 +1,48 @@ + +!include "nsDialogs.nsh" + +Var PathTextBoxHandle + +Function Page_SelectNWNPath + nsDialogs::Create 1018 + Pop $0 + + ${NSD_CreateLabel} 0 0 100% 12u "Please select your Neverwinter Nights install folder:" + Pop $1 + + ; Create a read-only text box to display the selected path + ${NSD_CreateText} 0 14u 75% 12u "$INSTPATH" + Pop $PathTextBoxHandle + + ; Create a "Browse..." button + ${NSD_CreateButton} 80% 14u 20% 12u "Browse..." + Pop $2 + ${NSD_OnClick} $2 OnBrowseClicked + + nsDialogs::Show +FunctionEnd + +Function OnBrowseClicked + nsDialogs::SelectFolderDialog "Select Neverwinter Nights Folder" "$INSTPATH" + Pop $0 + StrCmp $0 "" done + StrCpy $INSTPATH "$0" + ${NSD_SetText} $PathTextBoxHandle $INSTPATH +done: +FunctionEnd + +Function Page_SelectNWNPath_Validation + ; Get the current text in the folder path textbox + ${NSD_GetText} $PathTextBoxHandle $INSTPATH + + ; Check if tlk and hak folder exists + IfFileExists "$INSTPATH\tlk\*.*" 0 invalid + IfFileExists "$INSTPATH\hak\*.*" 0 invalid + + ; Everything is valid + Return + +invalid: + MessageBox MB_ICONEXCLAMATION|MB_OK "The selected folder must contain both 'tlk' and 'hak' subfolders." + Abort ; Prevents advancing to next page +FunctionEnd \ No newline at end of file diff --git a/installerico.ico b/installerico.ico new file mode 100644 index 0000000..e990e88 Binary files /dev/null and b/installerico.ico differ diff --git a/sinfarInstaller.nsi b/sinfarInstaller.nsi new file mode 100644 index 0000000..72b0377 --- /dev/null +++ b/sinfarInstaller.nsi @@ -0,0 +1,35 @@ +;!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