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
6307a3c194 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.
This commit is contained in:
Oliver Hamlet
2016-01-12 18:03:49 +00:00
parent 7fcbe0f95e
commit 4aff5a25dd
2 changed files with 53 additions and 110 deletions
-65
View File
@@ -1,65 +0,0 @@
# Example Default LOOT Settings File
# This file is written in YAML <http://www.yaml.org/>.
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
+53 -45
View File
@@ -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;