Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve steam initialization and game launch feedback #187

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/XIVLauncher.Core/Components/MainPage/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -821,15 +821,6 @@ public async Task<Process> StartGameAndAddon(Launcher.LoginResult loginResult, b
throw new NotImplementedException();
}

if (!Program.IsSteamDeckHardware)
{
Hide();
}
else
{
App.State = LauncherApp.LauncherState.SteamDeckPrompt;
}

// We won't do any sanity checks here anymore, since that should be handled in StartLogin
var launchedProcess = App.Launcher.LaunchGame(runner,
loginResult.UniqueId,
Expand All @@ -842,6 +833,17 @@ public async Task<Process> StartGameAndAddon(Launcher.LoginResult loginResult, b
App.Settings.IsEncryptArgs.GetValueOrDefault(true),
App.Settings.DpiAwareness.GetValueOrDefault(DpiAwareness.Unaware));

// Hide the launcher if not Steam Deck or if using as a compatibility tool (XLM)
// Show the Steam Deck prompt if on steam deck and not using as a compatibility tool
if (!Program.IsSteamDeckHardware || CoreEnvironmentSettings.IsSteamCompatTool)
{
Hide();
}
else
{
App.State = LauncherApp.LauncherState.SteamDeckPrompt;
}

if (launchedProcess == null)
{
Log.Information("GameProcess was null...");
Expand Down
5 changes: 3 additions & 2 deletions src/XIVLauncher.Core/CoreEnvironmentSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public static class CoreEnvironmentSettings
public static bool ClearAll => CheckEnvBool("XL_CLEAR_ALL");
public static bool? UseSteam => CheckEnvBoolOrNull("XL_USE_STEAM"); // Fix for Steam Deck users who lock themselves out
public static bool IsSteamCompatTool => CheckEnvBool("XL_SCT");
public static uint AltAppID => GetAltAppId(System.Environment.GetEnvironmentVariable("XL_APPID"));
public static uint SteamAppId => GetAppId(System.Environment.GetEnvironmentVariable("SteamAppId"));
public static uint AltAppID => GetAppId(System.Environment.GetEnvironmentVariable("XL_APPID"));

private static bool CheckEnvBool(string key)
{
Expand All @@ -40,7 +41,7 @@ public static string GetCleanEnvironmentVariable(string envvar, string badstring
return string.Join(separator, Array.FindAll<string>(dirty.Split(separator, StringSplitOptions.RemoveEmptyEntries), s => !s.Contains(badstring)));
}

public static uint GetAltAppId(string? appid)
public static uint GetAppId(string? appid)
{
uint.TryParse(appid, out var result);

Expand Down
48 changes: 24 additions & 24 deletions src/XIVLauncher.Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,29 +198,25 @@ private static void Main(string[] args)

Loc.SetupWithFallbacks();

uint appId, altId;
string appName, altName;
// AppId of 0 is invalid (though still a valid uint)
if (CoreEnvironmentSettings.AltAppID > 0)
Dictionary<uint, string> apps = new Dictionary<uint, string>();
uint[] ignoredIds = { 0, STEAM_APP_ID, STEAM_APP_ID_FT};
if (!ignoredIds.Contains(CoreEnvironmentSettings.SteamAppId))
{
appId = CoreEnvironmentSettings.AltAppID;
altId = STEAM_APP_ID_FT;
appName = $"Override AppId={appId.ToString()}";
altName = "FFXIV Free Trial";
apps.Add(CoreEnvironmentSettings.SteamAppId, "XLM");
}
else if (Config.IsFt == true)
if (!ignoredIds.Contains(CoreEnvironmentSettings.AltAppID))
{
appId = STEAM_APP_ID_FT;
altId = STEAM_APP_ID;
appName = "FFXIV Free Trial";
altName = "FFXIV Retail";
apps.Add(CoreEnvironmentSettings.AltAppID, "XL_APPID");
}
if (Config.IsFt == true)
{
apps.Add(STEAM_APP_ID_FT, "FFXIV Free Trial");
apps.Add(STEAM_APP_ID, "FFXIV Retail");
}
else
{
appId = STEAM_APP_ID;
altId = STEAM_APP_ID_FT;
appName = "FFXIV Retail";
altName = "FFXIV Free Trial";
apps.Add(STEAM_APP_ID, "FFXIV Retail");
apps.Add(STEAM_APP_ID_FT, "FFXIV Free Trial");
}
try
{
Expand All @@ -239,14 +235,18 @@ private static void Main(string[] args)
}
if (Config.IsIgnoringSteam != true || CoreEnvironmentSettings.IsSteamCompatTool)
{
try
{
Steam.Initialize(appId);
}
catch (Exception ex)
foreach (var app in apps)
{
Log.Error(ex, $"Couldn't init Steam with AppId={appId} ({appName}), trying AppId={altId} ({altName})");
Steam.Initialize(altId);
try
{
Steam.Initialize(app.Key);
Log.Information($"Successfully initialized Steam entry {app.Key} - {app.Value}");
break;
}
catch (Exception ex)
{
Log.Error(ex, $"Failed to initialize Steam Steam entry {app.Key} - {app.Value}");
}
}
}
}
Expand Down
Loading