From 4aff5a25dd3517f784501f1f2fc19506d0d96cae Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Tue, 12 Jan 2016 18:03:49 +0000 Subject: [PATCH] Don't install settings file The installer only installs a settings file so that it can set LOOT's language to that chosen for the installer. However, as of 6307a3c1944d6b66a5cf3e666e985629c1e58553 LOOT can load partial settings files, so the installer just needs to write out the language string to a new settings file if one is not already present. This then means the repository's settings.yaml can be removed. Closes #527. --- resources/settings.yaml | 65 --------------------------- scripts/installer.iss | 98 ++++++++++++++++++++++------------------- 2 files changed, 53 insertions(+), 110 deletions(-) delete mode 100644 resources/settings.yaml diff --git a/resources/settings.yaml b/resources/settings.yaml deleted file mode 100644 index db64f4d3..00000000 --- a/resources/settings.yaml +++ /dev/null @@ -1,65 +0,0 @@ -# Example Default LOOT Settings File -# This file is written in YAML . - -language: en # A locale code (see resources\l10n subfolders). - -game: auto # auto, or one of the 'folder' values below. -lastGame: auto # auto, or one of the 'folder' values below. -enableDebugLogging: false -updateMasterlist: true - -# Games. The four types are 'Oblivion', 'Skyrim', 'Fallout3' and 'FalloutNV'. They correspond to each base game's libespm and libloadorder settings. -games: - - folder: Oblivion - name: "TES IV: Oblivion" - type: Oblivion - master: Oblivion.esm - repo: https://github.com/loot/oblivion.git - branch: master - path: ~ - registry: Software\Bethesda Softworks\Oblivion\Installed Path - - - folder: Skyrim - name: "TES V: Skyrim" - type: Skyrim - master: Skyrim.esm - repo: https://github.com/loot/skyrim.git - branch: master - path: ~ - registry: Software\Bethesda Softworks\Skyrim\Installed Path - - - folder: Fallout3 - name: Fallout 3 - type: Fallout3 - master: Fallout3.esm - repo: https://github.com/loot/fallout3.git - branch: master - path: ~ - registry: Software\Bethesda Softworks\Fallout3\Installed Path - - - folder: FalloutNV - name: "Fallout: New Vegas" - type: FalloutNV - master: FalloutNV.esm - repo: https://github.com/loot/falloutnv.git - branch: master - path: ~ - registry: Software\Bethesda Softworks\FalloutNV\Installed Path - - - folder: Fallout4 - name: "Fallout 4" - type: Fallout4 - master: Fallout4.esm - repo: https://github.com/loot/fallout4.git - branch: master - path: ~ - registry: Software\Bethesda Softworks\Fallout4\Installed Path - - - folder: Nehrim - name: Nehrim - At Fate's Edge - type: Oblivion - master: Nehrim.esm - repo: https://github.com/loot/oblivion.git - branch: master - path: ~ - registry: Software\Microsoft\Windows\CurrentVersion\Uninstall\Nehrim - At Fate's Edge_is1\InstallLocation diff --git a/scripts/installer.iss b/scripts/installer.iss index 254b8230..9c9bc3cd 100644 --- a/scripts/installer.iss +++ b/scripts/installer.iss @@ -134,11 +134,7 @@ DestDir: "{app}\resources\l10n\ru\LC_MESSAGES"; Flags: ignoreversion Source: "resources\l10n\zh_CN\LC_MESSAGES\loot.mo"; \ DestDir: "{app}\resources\l10n\zh_CN\LC_MESSAGES"; Flags: ignoreversion -Source: "resources\settings.yaml"; \ -DestDir: "{localappdata}\{#MyAppName}"; Flags: onlyifdoesntexist uninsneveruninstall; AfterInstall: SetLOOTLanguage -; NOTE: Don't use "Flags: ignoreversion" on any shared system files - -[Icons] +[Icons] Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon @@ -191,30 +187,6 @@ zh_CN.DeleteUserFiles=你想要删除你的设置和用户数据吗? es.DeleteUserFiles=¿Quieres borrar sus ajustes y metadatos de usuario? [Code] -// Set LOOT's language in settings.yaml -procedure SetLOOTLanguage(); -var - SearchLineStart: String; - ReplaceLine: String; - Lines: TArrayOfString; - I: Integer; -begin - if ActiveLanguage = 'en' then - exit; - - SearchLineStart := 'language:'; - ReplaceLine := 'language: ' + ActiveLanguage; - - if LoadStringsFromFile(ExpandConstant(CurrentFileName), Lines) = True then begin - for I := 0 to GetArrayLength(Lines) - 1 do begin - if Copy(Lines[I], 0, Length(SearchLineStart)) = SearchLineStart then begin - Lines[I] := ReplaceLine; - SaveStringsToUTF8File(ExpandConstant(CurrentFileName), Lines, False) - Break; - end; - end; - end; -end; // Query user whether their data files should be deleted on uninstall. procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep); begin @@ -235,28 +207,64 @@ begin end; end; end; +// Set LOOT's language in settings.yaml +procedure SetLootLanguage(); +var + LanguageLine: String; + File: String; + SearchLineStart: String; + Lines: TArrayOfString; + I: Integer; +begin + LanguageLine := 'language: ' + ActiveLanguage; + File := ExpandConstant('{localappdata}\{#MyAppName}\settings.yaml'); + + if FileExists(File) then begin + SearchLineStart := 'language:'; + + if LoadStringsFromFile(File, Lines) = True then begin + for I := 0 to GetArrayLength(Lines) - 1 do begin + if Copy(Lines[I], 0, Length(SearchLineStart)) = SearchLineStart then begin + Lines[I] := LanguageLine; + SaveStringsToUTF8File(File, Lines, False) + Break; + end; + end; + end; + end + else begin + if ActiveLanguage <> 'en' then + SaveStringToFile(File, LanguageLine, False); + end; +end; // Run a previous install's uninstaller before starting this installation. -procedure CurStepChanged(CurStep: TSetupStep); +procedure RunPreviousVersionUninstaller(); var RegKey: String; RegValue: String; ResultCode: Integer; begin - if CurStep = ssInstall then begin - // First try using the Inno Setup installer's uninstall Registry key to get - // the uninstaller's path. This is necessary instead of just using the - // backwards-compatible key because the filename of the uninstaller created - // by Inno Setup can vary. - RegKey := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1'); - if RegQueryStringValue(HKLM, RegKey, 'UninstallString', RegValue) then begin - Exec(RemoveQuotes(RegValue), '/VERYSILENT', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); - // Now try using the backwards-compatible Registry key, and run the NSIS - // uninstaller, which has a fixed filename. - end - else begin - if RegQueryStringValue(HKLM, 'Software\LOOT', 'Installed Path', RegValue) then begin - Exec(RegValue + '\Uninstall.exe', '/S', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); - end; + // First try using the Inno Setup installer's uninstall Registry key to get + // the uninstaller's path. This is necessary instead of just using the + // backwards-compatible key because the filename of the uninstaller created + // by Inno Setup can vary. + RegKey := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1'); + if RegQueryStringValue(HKLM, RegKey, 'UninstallString', RegValue) then begin + Exec(RemoveQuotes(RegValue), '/VERYSILENT', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); + // Now try using the backwards-compatible Registry key, and run the NSIS + // uninstaller, which has a fixed filename. + end + else begin + if RegQueryStringValue(HKLM, 'Software\LOOT', 'Installed Path', RegValue) then begin + Exec(RegValue + '\Uninstall.exe', '/S', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); end; end; end; +procedure CurStepChanged(CurStep: TSetupStep); +begin + if CurStep = ssInstall then + RunPreviousVersionUninstaller(); + + if CurStep = ssPostInstall then + SetLootLanguage(); +end;