herdell
14th February 2011 12:23 UTC
Browse button
Hi, I wanna a nsis script that changes the 'Browse' button properties. Instead show this when I click in 'Browse' button:
http://img153.imageshack.us/img153/8653/snap1wl.jpg
I need to replace to this:
http://img831.imageshack.us/img831/6826/snap2d.jpg
Cause i'm a game translator, and my translations need to be installed in game install dir, so, if I can replace this function to search for the .exe of the game, instead of indicate the folder, would be nice.
Maybe it can do using installoptions with .ini file, or nsdialogs, but I don't know how.
Thanks in advance...
Highcoder
14th February 2011 13:08 UTC
You can use the standard Folder Dialog and combine it with .onVerifyInstDir.
Quote from NSIS Manual:
This callback enables control over whether or not an installation path is valid for your installer. This code will be called every time the user changes the install directory, so it shouldn't do anything crazy with MessageBox or the likes. If this function calls Abort, the installation path in $INSTDIR is deemed invalid.
Example:
Function .onVerifyInstDir
IfFileExists $INSTDIR\Winamp.exe PathGood ;replace with "somegame.exe" or "somegame.str"
Abort ; if $INSTDIR is not the game directory, don't let us install there
PathGood:
FunctionEnd
Should work for you and you don´t have to create a custom Page.
Sincerely...
herdell
14th February 2011 16:14 UTC
I already use this to prevent the user choice the incorrect folder.
Anyway, thanks...
Afrow UK
14th February 2011 17:58 UTC
Search for the exe before you display the directory page. You just need to set $INSTDIR. Also, avoid searching the file system if possible. You really should look for a registry value that tells you where the exe is. If you can't avoid searching the file system, make sure you indicate that a search is occurring using the Banner plug-in (or one of the more advanced ones such as nxs).
Stu
Highcoder
15th February 2011 08:49 UTC
Re...
You want the installer to find the gamedir automatically so that the user don´t have to browse for thr right directory. Right?
Why don´t you simply read out the game install dir from registry?
Almost all games/apps store it´s installdir in registry under HKEY_LOCAL_MACHINE\Software\myGame\installdir or something...
Just look into registry an search for the right key.
So you can predefine $instdir in your nsis script.
InstallDirRegKey HKLM "SOFTWARE\Activision\Call of duty Black ops" "installdir" <- example, i don´t know the right key
If the key was found $instdir contains the gamedirectory. If not it contains "" and you have to browse or you can do more checkups.