Added Steam update message box to the launcher

This commit is contained in:
Eddoursul 2026-10-18 15:23:21 +02:00
parent 11a9cf118a
commit 59efc154d8

View File

@ -51,6 +51,7 @@ Global Const $REG_KEY = "HKEY_CURRENT_USER\Software\SureAI\EnderalSE"
Global Const $REG_INSTALL_PATH = "Install_Path"
Global Const $REG_EXE_PATH = "Exe_Path"
Global Const $REG_START_STEAM = "Start_Steam"
Global Const $REG_STEAM_UPDATE_NOTICE_SHOWN = "Steam_Update_Notice_Shown"
Global Const $AA_TAA = "TAA (Best quality)"
Global Const $AA_FXAA = "FXAA (Low)"
Global Const $AA_OFF = "Off (Best performance)"
@ -358,9 +359,9 @@ Func GetEnderalVersion()
EndFunc
; ============================================
; Update Function
; Update Functions
; ============================================
Func CheckAndApplyUpdate()
Func CheckAndApplyGOGUpdate()
; Check if update is needed: SkyrimSE.exe is not 1.6.659 AND skse64_1_6_659.dll exists
Local $skyrimVersion = GetSkyrimVersion()
Local $oldSkseDll = $LAUNCHER_DIR & "\skse64_1_6_659.dll"
@ -509,6 +510,71 @@ Func CheckAndApplyUpdate()
EndIf
EndFunc
Func CheckAndNotifySteamUpdate()
; 2.1+ uses a new savegame location, the savegames in the old one are playable on the 2.0.12.4 branch only
If Not FileExists($LAUNCHER_DIR & "\steam_api64.dll") Then Return
If Not FileExists($LAUNCHER_DIR & "\Data\SKSE\Plugins\SkyrimRedirector.dll") Then Return
If GetEnderalVersion() = "2.0.12.4" Then Return
If RegRead($REG_KEY, $REG_STEAM_UPDATE_NOTICE_SHOWN) = 1 Then Return
Local $oldSavesDir = GetDocumentsPath() & "\My Games\Enderal Special Edition\Saves\"
Local $hSearch = FileFindFirstFile($oldSavesDir & "*.ess")
If $hSearch = -1 Then Return
FileClose($hSearch)
Local $iButton = ShowTwoButtonDialog("Enderal Special Edition", _
"Enderal SE has been updated. To continue playing your old savegames in " & $oldSavesDir & _
", please, switch to the 2.0.12.4 branch on Steam.", "OK", "Never show again")
If $iButton = 2 Then RegWrite($REG_KEY, $REG_STEAM_UPDATE_NOTICE_SHOWN, "REG_DWORD", 1)
EndFunc
Func ShowTwoButtonDialog($sTitle, $sText, $sButton1, $sButton2)
; Warning message box with custom button labels, which MsgBox does not support.
; Returns 1 or 2 for the clicked button, 0 when the dialog was closed with Esc or the close button.
Local Const $TDF_ALLOW_DIALOG_CANCELLATION = 0x0008
Local Const $TD_WARNING_ICON = 0xFFFF
; Distinct from IDOK/IDCANCEL, which TaskDialogIndirect returns when the dialog is cancelled
Local Const $BUTTON_ID_BASE = 100
Local $tStrings = DllStructCreate("wchar Title[" & StringLen($sTitle) + 1 & "];wchar Text[" & StringLen($sText) + 1 & _
"];wchar Button1[" & StringLen($sButton1) + 1 & "];wchar Button2[" & StringLen($sButton2) + 1 & "]")
DllStructSetData($tStrings, "Title", $sTitle)
DllStructSetData($tStrings, "Text", $sText)
DllStructSetData($tStrings, "Button1", $sButton1)
DllStructSetData($tStrings, "Button2", $sButton2)
; TASKDIALOG_BUTTON and TASKDIALOGCONFIG are packed (pshpack1.h)
Local $tButtons = DllStructCreate("align 1;int Id1;ptr Text1;int Id2;ptr Text2")
DllStructSetData($tButtons, "Id1", $BUTTON_ID_BASE + 1)
DllStructSetData($tButtons, "Text1", DllStructGetPtr($tStrings, "Button1"))
DllStructSetData($tButtons, "Id2", $BUTTON_ID_BASE + 2)
DllStructSetData($tButtons, "Text2", DllStructGetPtr($tStrings, "Button2"))
Local $tConfig = DllStructCreate("align 1;uint Size;hwnd Parent;handle Instance;dword Flags;dword CommonButtons;" & _
"ptr WindowTitle;ptr MainIcon;ptr MainInstruction;ptr Content;uint ButtonCount;ptr Buttons;int DefaultButton;" & _
"uint RadioButtonCount;ptr RadioButtons;int DefaultRadioButton;ptr VerificationText;ptr ExpandedInformation;" & _
"ptr ExpandedControlText;ptr CollapsedControlText;ptr FooterIcon;ptr Footer;ptr Callback;ptr CallbackData;uint Width")
DllStructSetData($tConfig, "Size", DllStructGetSize($tConfig))
DllStructSetData($tConfig, "Flags", $TDF_ALLOW_DIALOG_CANCELLATION)
DllStructSetData($tConfig, "WindowTitle", DllStructGetPtr($tStrings, "Title"))
DllStructSetData($tConfig, "MainIcon", $TD_WARNING_ICON)
DllStructSetData($tConfig, "Content", DllStructGetPtr($tStrings, "Text"))
DllStructSetData($tConfig, "ButtonCount", 2)
DllStructSetData($tConfig, "Buttons", DllStructGetPtr($tButtons))
DllStructSetData($tConfig, "DefaultButton", $BUTTON_ID_BASE + 1)
Local $aCall = DllCall("comctl32.dll", "long", "TaskDialogIndirect", "struct*", $tConfig, "int*", 0, "ptr", 0, "ptr", 0)
If @error Or $aCall[0] <> 0 Then
; Fallback without the custom buttons, so that the message is not lost
MsgBox(48, $sTitle, $sText)
Return 1
EndIf
Local $iButton = $aCall[2] - $BUTTON_ID_BASE
If $iButton = 1 Or $iButton = 2 Then Return $iButton
Return 0
EndFunc
; ============================================
; Main Entry Point
; ============================================
@ -516,7 +582,8 @@ Main()
Func Main()
; Check and apply update if needed
CheckAndApplyUpdate()
CheckAndApplyGOGUpdate()
CheckAndNotifySteamUpdate()
; Check if SkyrimRedirector is installed
Local $redirectorDll = $LAUNCHER_DIR & "\Data\SKSE\Plugins\SkyrimRedirector.dll"