Skip to content
⌘ NSIS Forum Archive

ModernUI and .onVerifyInstDir

4 posts

Pyrii#

ModernUI and .onVerifyInstDir

I recently updated to the newer NSIS2 and converted one of my old scripts for the same task. Thought I'd put a bit of n00b control back in aswell by verifying that they at least have the game installed for the patch. It tells me it's the wrong dir good, when I click browse, it decides to tell me another 6 times before letting me select a different directory.

I'm using ModernUI (As the topic says)

Here's the function as it is now:

Function .onVerifyInstDir
IfFileExists $INSTDIR\data.grf finenorm oops
oops:
MessageBox MB_OK|MB_ICONEXCLAMATION|MB_TOPMOST "You don't have Ragnarok Online Installed in the Directory selected."
Abort
finenorm:
IfFileExists $INSTDIR\sdata.grf carryon nosak
nosak:
MessageBox MB_OK|MB_ICONEXCLAMATION|MB_TOPMOST "You don't have Sakray Installed. Make sure It's installed into your Ragnarok Online Directory before patching."
Abort
carryon:
FunctionEnd
Is there anoy sort of workaround? Or another function to use?
Joost Verburg#
Change a label text or something else. Using a message box is not a good idea because this function is called every time the user changes the directory. If you display a message box every time the user pressed a key it will become almost impossible to enter a name.
Pyrii#
I decided to use the MUI_PAGE_CUSTOMFUNCTION_LEAVE instead. Which is nicer I suppose.

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE verifydir
!insertmacro MUI_PAGE_DIRECTORY

...

Function verifydir

...

FunctionEnd
EDIT: It showed 6 times before the browse window actually popped up. After that it was fine again. Could ModernUI be fiddling with the directory before opening the browse window?
Joost Verburg#
The Modern UI has nothing do this with this validation. It is indeed possible that it checks multiple times, that depends on the window messages and user input recieved.