aboutsummaryrefslogtreecommitdiffstats
path: root/installer/UltraStar Deluxe.nsi
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-06-08 18:18:29 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-06-08 18:18:29 +0000
commite73913f7f2d00a26741b266ca29d5b45c5896651 (patch)
treec7b6d93354435288a11fc6c9db7ac14a776cfe1b /installer/UltraStar Deluxe.nsi
parent09809c48f227ffa2bb0fc3948b2ef336ab0110f5 (diff)
downloadusdx-e73913f7f2d00a26741b266ca29d5b45c5896651.tar.gz
usdx-e73913f7f2d00a26741b266ca29d5b45c5896651.tar.xz
usdx-e73913f7f2d00a26741b266ca29d5b45c5896651.zip
installer adjusted to config.ini detection
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2455 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'installer/UltraStar Deluxe.nsi')
-rw-r--r--installer/UltraStar Deluxe.nsi102
1 files changed, 76 insertions, 26 deletions
diff --git a/installer/UltraStar Deluxe.nsi b/installer/UltraStar Deluxe.nsi
index 497f53ee..125dfefc 100644
--- a/installer/UltraStar Deluxe.nsi
+++ b/installer/UltraStar Deluxe.nsi
@@ -7,6 +7,7 @@
!include LogicLib.nsh
!include InstallOptions.nsh
!include nsDialogs.nsh
+!include UAC.nsh
; ~+~ ~+~ ~+~ ~+~ ~+~ ~+~ ~+~ ~+~ ~+~ ~+~ ~+~ ~+~
; Variables
@@ -49,8 +50,8 @@ InstallDir "$PROGRAMFILES\${name}"
InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UltraStar Deluxe" "InstallDir"
; Windows Vista / Windows 7:
-
-RequestExecutionLevel admin
+; must be "user" for UAC plugin
+RequestExecutionLevel user
; ~+~ ~+~ ~+~ ~+~ ~+~ ~+~ ~+~ ~+~ ~+~ ~+~ ~+~ ~+~
; Interface Settings
@@ -109,8 +110,16 @@ RequestExecutionLevel admin
!define MUI_FINISHPAGE_TEXT_LARGE
!define MUI_FINISHPAGE_TEXT "$(page_finish_txt)"
-!define MUI_FINISHPAGE_RUN "$INSTDIR\${exe}.exe"
+; MUI_FINISHPAGE_RUN is executed as admin by default.
+; To get the config.ini location right it must be executed with user
+; rights instead.
+!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_NOTCHECKED
+!define MUI_FINISHPAGE_RUN_FUNCTION RunAppAsUser
+
+Function RunAppAsUser
+ UAC::ShellExec 'open' '' '$INSTDIR\${exe}.exe' '' '$INSTDIR'
+FunctionEnd
!define MUI_FINISHPAGE_LINK "$(page_finish_linktxt)"
!define MUI_FINISHPAGE_LINK_LOCATION "${homepage}"
@@ -135,7 +144,7 @@ RequestExecutionLevel admin
; Start menu page
-var ICONS_GROUP
+Var ICONS_GROUP
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "${name}"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
@@ -149,6 +158,50 @@ var ICONS_GROUP
Page custom Settings
+
+; User data info
+
+Var UseAppData ; true if APPDATA is used for user data, false for INSTDIR
+Var UserDataPath ; Path to user data dir (e.g. $INSTDIR)
+Var ConfigIniPath ; Path to config.ini (e.g. "$INSTDIR\config.ini")
+
+; Checks for write permissions on $INSTDIR\config.ini.
+; This function creates $INSTDIR\config.use as a marker file if
+; the user has write permissions.
+; Note: Must be run with user privileges
+Function CheckInstDirUserPermissions
+ ClearErrors
+ ; try to open the ini file.
+ ; Use "append" mode so an existing config.ini is not destroyed.
+ FileOpen $0 "$INSTDIR\config.ini" a
+ IfErrors end
+ ; we have write permissions -> create a marker file
+ FileOpen $1 "$INSTDIR\config.use" a
+ FileClose $1
+end:
+ FileClose $0
+FunctionEnd
+
+; Determines the directory used for config.ini and other user
+; settings and data.
+; Sets $UseAppData, $UserDataPath and $ConfigIniPath
+Function DetermineUserDataDir
+ Delete "$INSTDIR\config.use"
+ !insertmacro UAC.CallFunctionAsUser CheckInstDirUserPermissions
+ IfFileExists "$INSTDIR\config.use" 0 notexists
+ StrCpy $UseAppData false
+ StrCpy $UserDataPath "$INSTDIR"
+ Goto end
+notexists:
+ StrCpy $UseAppData true
+ SetShellVarContext current
+ StrCpy $UserDataPath "$APPDATA\ultrastardx"
+ SetShellVarContext all
+end:
+ Delete "$INSTDIR\config.use"
+ StrCpy $ConfigIniPath "$UserDataPath\config.ini"
+FunctionEnd
+
Function Settings
!insertmacro INSTALLOPTIONS_WRITE "Settings-$LANGUAGE" "Field 18" "State" "$INSTDIR\songs"
@@ -187,32 +240,17 @@ Function Settings
!insertmacro INSTALLOPTIONS_READ $sorting "Settings-$LANGUAGE" "Field 15" "State"
!insertmacro INSTALLOPTIONS_READ $songdir "Settings-$LANGUAGE" "Field 18" "State"
- ; Write all variables to config.ini
-
- var /GLOBAL path_config
- var /GLOBAL path_configini
-
- ${If} ${AtLeastWinVista}
- SetShellVarContext current
- StrCpy $path_config "$APPDATA\ultrastardx"
- SetShellVarContext all
- ${Else}
- StrCpy $path_config "$INSTDIR"
- ${EndIf}
-
- StrCpy $path_configini "$path_config\config.ini"
-
- WriteINIStr "$path_configini" "Game" "Language" "$language2"
- WriteINIStr "$path_configini" "Game" "Tabs" "$tabs"
- WriteINIStr "$path_configini" "Game" "Sorting" "$sorting"
+ WriteINIStr "$ConfigIniPath" "Game" "Language" "$language2"
+ WriteINIStr "$ConfigIniPath" "Game" "Tabs" "$tabs"
+ WriteINIStr "$ConfigIniPath" "Game" "Sorting" "$sorting"
- WriteINIStr "$path_configini" "Graphics" "FullScreen" "$fullscreen"
- WriteINIStr "$path_configini" "Graphics" "Resolution" "$resolution"
+ WriteINIStr "$ConfigIniPath" "Graphics" "FullScreen" "$fullscreen"
+ WriteINIStr "$ConfigIniPath" "Graphics" "Resolution" "$resolution"
${If} $songdir != "$INSTDIR\songs"
- WriteINIStr "$path_configini" "Directories" "SongDir1" "$songdir"
+ WriteINIStr "$ConfigIniPath" "Directories" "SongDir1" "$songdir"
${EndIf}
-
+
FunctionEnd ; Settings page End
!insertmacro MUI_PAGE_FINISH
@@ -333,6 +371,8 @@ Section $(name_section1) Section1
SetOutPath $INSTDIR
SetOverwrite try
+ Call DetermineUserDataDir
+
!include "${path_settings}\files_main_install.nsh"
; Create Shortcuts:
@@ -487,6 +527,8 @@ FunctionEnd
Function .onInit
+ ${UAC.I.Elevate.AdminOnly}
+
var /GLOBAL version
StrCpy $version "1.1beta"
@@ -560,3 +602,11 @@ continue:
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
+
+Function .onInstFailed
+ ${UAC.Unload}
+FunctionEnd
+
+Function .onInstSuccess
+ ${UAC.Unload}
+FunctionEnd \ No newline at end of file