This is the repository for Yandols' Bachelor's Degree Final Year Project Game (2019). Game created in Construct 2 and Launcher/Updater is created with AHK.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ResistanceSaga/Launcher/rs-launcher.ahk

199 lines
5.8 KiB

; /* ------------------------------------------------------------ */
; Script Name : Resistance Saga FYP Launcher
; Version : 1.1.0.1008
; Author : Yandols Z'eon X
; Supported Platforms : 64-bit Windows platforms.
; /* ------------------------------------------------------------ */
#SingleInstance Ignore ; REMEMBER TO CHANGE TO IGNORE BEFORE COMPILING FOR RELEASE
#NoEnv
#NoTrayIcon
;#Warn ; DEBUG ONLY. REMEMBER TO REMOVE/COMMENT OUT THIS LINE BEFORE COMPILING FOR RELEASE
SendMode Input
SetWorkingDir %A_ScriptDir%
AppName=Resistance Saga Launcher
AppVer=1.1.0.1008
AppAuthor=YandolsZX
AppTitle=%AppName% (Version %AppVer%)
AppDataFolder=%A_AppData%\Locaria Technologies\RSF
ProductName=Resistance Saga
gosub Initialization
Gui, Add, Pic, x40 y-124 w-1 h600 BackgroundTrans, %A_Temp%\RSFL-Logo.png
Gui, Font, bold
Gui, Add, Button, x020 y236 w640 h36 vBtnStart gBtnStart Default, &Start Game
Gui, Font, norm
Gui, Add, Button, x020 y280 w200 h36 vBtnNews gBtnNews, &News
Gui, Add, Button, x240 y280 w200 h36 vBtnSettings gBtnSettings, &Options
Gui, Add, Button, x460 y280 w200 h36 vBtnQuit gBtnQuit, &Quit
Gui, Add, StatusBar,, ` Checking for Updates...
SB_SetParts(360, 120)
SB_SetText("A game by " . AppAuthor . " for his FYP.", 3)
Gui, Show, w680 h350, %AppName%
SetTimer, CheckUpdates, 300
GuiControl, Disable, BtnStart
Return
BtnStart:
Gui, Submit
RunWait, win64\rsaga.exe --disable-devtools,, UseErrorLevel
If ErrorLevel
{
Msgbox, 16, %AppName%, Failed to start the game. Please make sure the game is up to date and you have DirectX 10 installed. `n`nIf you think your installation is corrupted, use the 'Redownload Game Data' option in settings.
ExitApp, 13
}
Else
ExitApp
Return
BtnNews:
Run, https://yandols.xyz/resistance-saga,, UseErrorLevel
If ErrorLevel
MsgBox, 0, %AppName%, A reserved action failed to process.
Return
BtnSettings:
SetTimer, CheckUpdates, Off
Gui, Hide
Gui, 2:-MaximizeBox -MinimizeBox
Gui, 2:Add, GroupBox, x10 y10 w240 h90, Versions
Gui, 2:Add, Text, x20 y30, Launcher Version : %AppVer%
Gui, 2:Add, Text, x20 y50, Game Version : %ProductVer%
Gui, 2:Add, Text, x20 y70, Last Hash : %RSLastHash%
Gui, 2:Add, GroupBox, x10 y110 w240 h120, Tools:
Gui, 2:Add, Button, x20 y130 w220 h26 gBtnRedownload, Redownload &Game Data
Gui, 2:Add, Button, x20 y160 w220 h26 gBtnDirectX, (Re)install &DirectX
Gui, 2:Add, Button, x20 y190 w220 h26 gBtnClearData, &Clear Persistent User Data
Gui, 2:Add, Button, x20 y240 w220 h26 g2GuiClose Default, < &Back
Gui, 2:Show, w260 h280, %AppName% Settings
Return
BtnRedownload:
Gui, +OwnDialogs
If IsDownloadingFromScratch = 1
Goto RedownloadGameData
MsgBox, 52, Redownload Game Data, This will redownload the latest version of the game from the server. Normally used if there is something wrong with your installation of the game. Proceed?
IfMsgBox, Yes
Goto, RedownloadGameData
Else
Return
Return
RedownloadGameData:
RunWait, rs-updater.exe /forceupdate,, UseErrorLevel
If ErrorLevel
{
Msgbox, 16, Fatal Error, Updater failed to start because the component is missing.
ExitApp, 18
}
ExitApp
Return
BtnDirectX:
Gui, +OwnDialogs
RunWait, win64\dxwebsetup.exe,, UseErrorLevel
If ErrorLevel
{
Msgbox, 16, Fatal Error, Setup failed to start because the component is missing.
ExitApp, 17
}
Return
BtnClearData:
Gui, +OwnDialogs
Msgbox, 52, Clear Presistent User Data, This will delete all of the game's persistent user data and cache that is stored in your AppData. The game files and any save data are left intact and must be removed manually.
IfMsgBox, Yes
{
Gui, Hide
; -- Disabled because not currently working for some reason --
;FileDelete, %A_AppData%\ResistanceSaga\*.*
;FileDelete, %A_AppData%\ResistanceSagaFYP\*.*
;FileRemoveDir, %A_AppData%\ResistanceSaga, 1
;FileRemoveDir, %A_AppData%\ResistanceSagaFYP, 1
Msgbox, 16, Clear Persistent User Data, Operation failed. Something went wrong, the launcher was unable to clear any of the persistent user data. `n`nTo manually clear the user data, go to your Local AppData folder and delete the 'ResistanceSaga' and 'ResistanceSagaFYP' folders.
;Msgbox, 64, Clear Persistent User Data, User Data and Cache successfully deleted.
Reload
Return
}
IfMsgBox, No
Return
Return
2GuiEscape:
2GuiClose:
Gui, 2:Destroy
Gui, 1:Show
Return
CheckUpdates:
Thread, interrupt, 0
SetTimer, CheckUpdates, Off
/* -- DEPRECATED --
If NoUpdaterPrompt = true
return
*/
UrlDownloadToFile, https://kin.yandols.xyz/rs-fyp.ini, %A_Temp%/csu-resistancesaga-1.vc
If ErrorLevel
{
SB_SetText(" Unable to connect to patch server.", 1)
GuiControl, Enable, BtnStart
GuiControl, Focus, BtnStart
return
}
;; Read Remote Config
IniRead, CSU_NewVersion, %A_Temp%/csu-resistancesaga-1.vc, SingularityUpdater, VersionToUse, 0
IniRead, CSU_Identifier, %A_Temp%/csu-resistancesaga-1.vc, SingularityUpdater, Identifier, null
If CSU_Identifier = RESISTANCESAGA-FYP
{
If CSU_NewVersion != %ProductVer%
{
SB_SetText(" A new update has been found. (" . CSU_NewVersion . ")", 1)
SB_SetText(" Your Ver: " . ProductVer, 2)
Run, rs-updater.exe, %A_ScriptDir%, UseErrorLevel
If ErrorLevel
Msgbox, 16, Fatal Error, Updater failed to start because the component is missing.
}
Else
{
SB_SetText(" No updates found.", 1)
SB_SetText(" Your Ver: " . ProductVer, 2)
}
}
GuiControl, Enable, BtnStart
GuiControl, Focus, BtnStart
return
return
Initialization:
FileInstall, res\RS-Icon-G.png, %A_Temp%\RSFL-Icon.png, 1
FileInstall, res\RS-Title-G.png, %A_Temp%\RSFL-Logo.png, 1
FileRead, ProductVer, win64\rversion.txt
FileRead, RSLastHash, win64\rhash.txt
IfNotExist, rs-Updater.exe
FileInstall, rs-Updater.exe, rs-Updater.exe, 0
IfNotExist, win64
{
Msgbox, 4, %AppName%, Game data could not be found. Download now? (It will be installed in the directory where the launcher is.)
IfMsgBox, Yes
{
IsDownloadingFromScratch = 1
Goto BtnRedownload
}
Else
Return
}
Return
BtnQuit:
GuiEscape:
GuiClose:
ExitApp
Return