From b4341fbe9cd5d3de9a898abf1b9837a596d61f61 Mon Sep 17 00:00:00 2001 From: Jakob Gahde Date: Wed, 20 Sep 2023 22:36:20 +0200 Subject: [PATCH] Adapt installer UI strings for upgrades --- .../actions/create-package/create-package.sh | 2 +- util/installer/pencil2d.bundle.wxs | 2 +- util/installer/pencil2d.cpp | 36 +++++- util/installer/pencil2d.thm | 17 ++- util/installer/pencil2d.wxl | 7 +- util/installer/translations/pencil2d.wxl.xlf | 100 +++++++++-------- .../translations/pencil2d_de.wxl.xlf | 104 ++++++++++-------- 7 files changed, 161 insertions(+), 107 deletions(-) diff --git a/.github/actions/create-package/create-package.sh b/.github/actions/create-package/create-package.sh index b3ad8780d..fa40ba048 100755 --- a/.github/actions/create-package/create-package.sh +++ b/.github/actions/create-package/create-package.sh @@ -144,7 +144,7 @@ create_package_windows() { local basename="$(basename -s .wxl.xlf "$i")" local locale="${basename#*_}" local culture="${locale/_/-}" - local lcid="$(pwsh -c "(Get-Culture -Name ${culture}).lcid")" + local lcid="$(pwsh -c "(Get-Culture -Name ${culture}).LCID")" sed "s/Culture=\"en\"/Culture=\"${culture}\"/;s/Language=\"9\"/Language=\"${lcid}\"/" ../util/installer/pencil2d.wxl > "../util/installer/pencil2d_${locale}.wxl" tikal.bat -m -fc ../util/installer/okf_xml_wxl -ie utf-8 -oe utf-8 -sd ../util/installer -od ../util/installer "${i}" done diff --git a/util/installer/pencil2d.bundle.wxs b/util/installer/pencil2d.bundle.wxs index 9be25b678..c85624682 100644 --- a/util/installer/pencil2d.bundle.wxs +++ b/util/installer/pencil2d.bundle.wxs @@ -42,7 +42,7 @@ LocalizationFile="pencil2d.wxl" /> - + diff --git a/util/installer/pencil2d.cpp b/util/installer/pencil2d.cpp index 26dfe0cd9..11c00d3ab 100644 --- a/util/installer/pencil2d.cpp +++ b/util/installer/pencil2d.cpp @@ -10,6 +10,7 @@ #include "pathutil.h" #include "strutil.h" #include "thmutil.h" +#include "verutil.h" #include "xmlutil.h" #include "BootstrapperEngine.h" @@ -121,11 +122,36 @@ class Pencil2DBAFunctions : public CBalBaseBAFunctions __inout BOOL* pfCancel ) { - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Trying to recover installation options from related bundle %ls.", wzBundleId); - RecoverRelatedBundleStringVariable(wzBundleId, L"InstallFolder", TRUE); - RecoverRelatedBundleNumericVariable(wzBundleId, L"DesktopShortcut"); + HRESULT hr = S_OK; + LPWSTR sczVersion = NULL; + + if (relationType == BOOTSTRAPPER_RELATION_UPGRADE) + { + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Trying to recover installation options from related bundle %ls.", wzBundleId); + RecoverRelatedBundleStringVariable(wzBundleId, L"InstallFolder", TRUE); + RecoverRelatedBundleNumericVariable(wzBundleId, L"DesktopShortcut"); + + if (m_command.action == BOOTSTRAPPER_ACTION_INSTALL) + { + hr = BalGetVersionVariable(L"WixBundleVersion", &sczVersion); + BalExitOnFailure(hr, "Failed to get bundle version."); + + int nResult; + hr = VerCompareStringVersions(wzVersion, sczVersion, TRUE, &nResult); + BalExitOnFailure(hr, "Failed to compare bundle version: %ls to related bundle version: %ls.", sczVersion, wzVersion); - return __super::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, pfCancel); + if (nResult < 0) + { + BalSetNumericVariable(L"UpgradeDetected", 1); + } + } + } + + hr = __super::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, pfCancel); + + LExit: + ReleaseStr(sczVersion); + return hr; } virtual STDMETHODIMP OnPauseAutomaticUpdatesBegin() @@ -231,7 +257,6 @@ class Pencil2DBAFunctions : public CBalBaseBAFunctions { hr = BalSetStringVariable(wzVariable, wzValue, fFormatted); BalExitOnFailure(hr, "Failed to set variable %ls to recovered value %ls.", wzVariable, wzValue); - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Recovered related bundle variable %ls: %ls.", wzVariable, wzValue); } LExit: @@ -256,7 +281,6 @@ class Pencil2DBAFunctions : public CBalBaseBAFunctions hr = BalSetNumericVariable(wzVariable, llValue); BalExitOnFailure(hr, "Failed to set variable %ls to recovered value %lld.", wzVariable, llValue); - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Recovered related bundle variable %ls: %lld.", wzVariable, llValue); LExit: ReleaseStr(wzValue); diff --git a/util/installer/pencil2d.thm b/util/installer/pencil2d.thm index c06bbae20..ec522253e 100644 --- a/util/installer/pencil2d.thm +++ b/util/installer/pencil2d.thm @@ -13,9 +13,9 @@ -