1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-26 22:27:44 +00:00

Protect against crashes when running in non-Steam mode in Steam builds

This commit is contained in:
Joshua Goins 2022-09-08 00:03:59 -04:00
parent 9c02ea2157
commit 840539485d
2 changed files with 12 additions and 3 deletions

View file

@ -9,4 +9,7 @@ public:
void setLauncherMode(bool isLauncher);
bool isDeck() const;
private:
LauncherCore& core;
};

View file

@ -7,7 +7,7 @@
#include <steam/steam_api.h>
#endif
SteamAPI::SteamAPI(LauncherCore& core) {
SteamAPI::SteamAPI(LauncherCore& core) : core(core) {
#ifdef ENABLE_STEAM
if(core.isSteam) {
qputenv("SteamAppId", "39210");
@ -21,13 +21,19 @@ SteamAPI::SteamAPI(LauncherCore& core) {
void SteamAPI::setLauncherMode(bool isLauncher) {
#ifdef ENABLE_STEAM
SteamUtils()->SetGameLauncherMode(isLauncher);
if(core.isSteam) {
SteamUtils()->SetGameLauncherMode(isLauncher);
}
#endif
}
bool SteamAPI::isDeck() const {
#ifdef ENABLE_STEAM
return SteamUtils()->IsSteamRunningOnSteamDeck();
if(core.isSteam) {
return SteamUtils()->IsSteamRunningOnSteamDeck();
} else {
return false;
}
#else
return false;
#endif