;Copyright (C) 2004-2012 John T. Haller ;Website: http://PortableApps.com/SudokuPortable ;This software is OSI Certified Open Source Software. ;OSI Certified is a certification mark of the Open Source Initiative. ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either version 2 ;of the License, or (at your option) any later version. ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. !define PORTABLEAPPNAME "Sudoku Portable" !define NAME "SudokuPortable" !define APPNAME "Sudoku" !define VER "1.6.1.0" !define WEBSITE "PortableApps.com/SudokuPortable" !define DEFAULTEXE "sudoku.exe" !define DEFAULTAPPDIR "sudoku" !define DEFAULTSETTINGSDIR "settings" !define LAUNCHERLANGUAGE "English" ;=== Program Details Name "${PORTABLEAPPNAME}" OutFile "..\..\${NAME}.exe" Caption "${PORTABLEAPPNAME} | PortableApps.com" VIProductVersion "${VER}" VIAddVersionKey ProductName "${PORTABLEAPPNAME}" VIAddVersionKey Comments "Allows ${APPNAME} to be run from a removable drive. For additional details, visit ${WEBSITE}" VIAddVersionKey CompanyName "PortableApps.com" VIAddVersionKey LegalCopyright "John T. Haller" VIAddVersionKey FileDescription "${PORTABLEAPPNAME}" VIAddVersionKey FileVersion "${VER}" VIAddVersionKey ProductVersion "${VER}" VIAddVersionKey InternalName "${PORTABLEAPPNAME}" VIAddVersionKey LegalTrademarks "PortableApps.com is a Trademark of Rare Ideas, LLC." VIAddVersionKey OriginalFilename "${NAME}.exe" ;VIAddVersionKey PrivateBuild "" ;VIAddVersionKey SpecialBuild "" ;=== Runtime Switches CRCCheck On WindowIcon Off SilentInstall Silent AutoCloseWindow True RequestExecutionLevel user ; Best Compression SetCompress Auto SetCompressor /SOLID lzma SetCompressorDictSize 32 SetDatablockOptimize On XPStyle On !include FileFunc.nsh !insertmacro GetParameters !insertmacro GetParent !include LogicLib.nsh !include CheckForPlatformSplashDisable.nsh ;=== Program Icon Icon "..\..\App\AppInfo\appicon.ico" ;=== Languages LoadLanguageFile "${NSISDIR}\Contrib\Language files\${LAUNCHERLANGUAGE}.nlf" !include PortableApps.comLauncherLANG_${LAUNCHERLANGUAGE}.nsh Var PROGRAMDIRECTORY Var SETTINGSDIRECTORY Var ADDITIONALPARAMETERS Var EXECSTRING Var WAITFORPROGRAM Var PROGRAMEXECUTABLE Var INIPATH Var DISABLESPLASHSCREEN Var ISDEFAULTDIRECTORY Var MISSINGFILEORPATH Section "Main" ;=== Find the INI file, if there is one IfFileExists "$EXEDIR\${NAME}.ini" "" NoINI StrCpy "$INIPATH" "$EXEDIR" Goto ReadINI ReadINI: ;=== Read the parameters from the INI file ReadINIStr $0 "$INIPATH\${NAME}.ini" "${NAME}" "${APPNAME}Directory" StrCpy "$PROGRAMDIRECTORY" "$EXEDIR\$0" ReadINIStr $0 "$INIPATH\${NAME}.ini" "${NAME}" "SettingsDirectory" StrCpy "$SETTINGSDIRECTORY" "$EXEDIR\$0" ;=== Check that the above required parameters are present IfErrors NoINI ReadINIStr $0 "$INIPATH\${NAME}.ini" "${NAME}" "AdditionalParameters" StrCpy "$ADDITIONALPARAMETERS" $0 ReadINIStr $0 "$INIPATH\${NAME}.ini" "${NAME}" "WaitFor${APPNAME}" StrCpy "$WAITFORPROGRAM" $0 ReadINIStr $0 "$INIPATH\${NAME}.ini" "${NAME}" "${APPNAME}Executable" StrCpy "$PROGRAMEXECUTABLE" $0 ReadINIStr $0 "$INIPATH\${NAME}.ini" "${NAME}" "DisableSplashScreen" StrCpy "$DISABLESPLASHSCREEN" $0 ;CleanUpAnyErrors: ;=== Any missing unrequired INI entries will be an empty string, ignore associated errors ClearErrors ;=== Correct PROGRAMEXECUTABLE if blank StrCmp $PROGRAMEXECUTABLE "" "" EndINI StrCpy "$PROGRAMEXECUTABLE" "${DEFAULTEXE}" Goto EndINI NoINI: ;=== No INI file, so we'll use the defaults StrCpy "$ADDITIONALPARAMETERS" "" StrCpy "$WAITFORPROGRAM" "false" StrCpy "$PROGRAMEXECUTABLE" "${DEFAULTEXE}" StrCpy "$DISABLESPLASHSCREEN" "false" IfFileExists "$EXEDIR\App\${DEFAULTAPPDIR}\${DEFAULTEXE}" "" NoProgramEXE StrCpy "$PROGRAMDIRECTORY" "$EXEDIR\App\${DEFAULTAPPDIR}" StrCpy "$SETTINGSDIRECTORY" "$EXEDIR\Data\${DEFAULTSETTINGSDIR}" StrCpy "$ISDEFAULTDIRECTORY" "true" GoTo EndINI EndINI: IfFileExists "$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" FoundProgramEXE NoProgramEXE: ;=== Program executable not where expected StrCpy $MISSINGFILEORPATH $PROGRAMEXECUTABLE MessageBox MB_OK|MB_ICONEXCLAMATION `$(LauncherFileNotFound)` Abort FoundProgramEXE: IfFileExists "$SETTINGSDIRECTORY\*.*" SettingsFound ;=== No profile was found StrCmp $ISDEFAULTDIRECTORY "true" CopyDefaultSettings StrCpy $MISSINGFILEORPATH $SETTINGSDIRECTORY MessageBox MB_OK|MB_ICONEXCLAMATION `$(LauncherFileNotFound)` Abort CopyDefaultSettings: CreateDirectory "$EXEDIR\Data" CreateDirectory "$EXEDIR\Data\${DEFAULTSETTINGSDIR}" SettingsFound: ${CheckForPlatformSplashDisable} $DISABLESPLASHSCREEN StrCmp $DISABLESPLASHSCREEN "true" GetPassedParameters ;=== Show the splash screen before processing the files InitPluginsDir File /oname=$PLUGINSDIR\splash.jpg "${NAME}.jpg" newadvsplash::show /NOUNLOAD 1200 0 0 -1 /L $PLUGINSDIR\splash.jpg GetPassedParameters: ;=== Get any passed parameters ${GetParameters} $0 StrCmp "'$0'" "''" "" LaunchProgramParameters ;=== No parameters StrCpy $EXECSTRING `"$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE"` Goto AdditionalParameters LaunchProgramParameters: StrCpy $EXECSTRING `"$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" $0` AdditionalParameters: StrCmp $ADDITIONALPARAMETERS "" UserProfileEnvironment ;=== Additional Parameters StrCpy $EXECSTRING `$EXECSTRING $ADDITIONALPARAMETERS` UserProfileEnvironment: ;=== Set the %USERPROFILE% directory if we have a path System::Call 'Kernel32::SetEnvironmentVariable(t, t) i("USERPROFILE", "$SETTINGSDIRECTORY").r0' ;LaunchNow: StrCmp $WAITFORPROGRAM "true" LaunchAndWait LaunchAndClose LaunchAndWait: ExecWait $EXECSTRING Goto TheEnd LaunchAndClose: Exec $EXECSTRING TheEnd: newadvsplash::stop /WAIT SectionEnd