Skip to content

Commit

Permalink
refactor: remove flatpak update check
Browse files Browse the repository at this point in the history
  • Loading branch information
Blooym committed Nov 28, 2024
1 parent cd69a2d commit bd5d622
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 281 deletions.
45 changes: 0 additions & 45 deletions src/XIVLauncher.Core/Components/UpdateWarnPage.cs

This file was deleted.

13 changes: 6 additions & 7 deletions src/XIVLauncher.Core/CoreEnvironmentSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public static class CoreEnvironmentSettings
public static bool? IsDeck => CheckEnvBoolOrNull("XL_DECK");
public static bool? IsDeckGameMode => CheckEnvBoolOrNull("XL_GAMEMODE");
public static bool? IsDeckFirstRun => CheckEnvBoolOrNull("XL_FIRSTRUN");
public static bool IsUpgrade => CheckEnvBool("XL_SHOW_UPGRADE");
public static bool ClearSettings => CheckEnvBool("XL_CLEAR_SETTINGS");
public static bool ClearPrefix => CheckEnvBool("XL_CLEAR_PREFIX");
public static bool ClearPlugins => CheckEnvBool("XL_CLEAR_PLUGINS");
Expand All @@ -16,19 +15,19 @@ 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 SteamAppId => GetAppId(System.Environment.GetEnvironmentVariable("SteamAppId"));
public static uint AltAppID => GetAppId(System.Environment.GetEnvironmentVariable("XL_APPID"));
public static uint SteamAppId => GetAppId(Environment.GetEnvironmentVariable("SteamAppId"));
public static uint AltAppID => GetAppId(Environment.GetEnvironmentVariable("XL_APPID"));

private static bool CheckEnvBool(string key)
{
string val = (System.Environment.GetEnvironmentVariable(key) ?? string.Empty).ToLower();
string val = (Environment.GetEnvironmentVariable(key) ?? string.Empty).ToLower();
if (val == "1" || val == "true" || val == "yes" || val == "y" || val == "on") return true;
return false;
}

private static bool? CheckEnvBoolOrNull(string key)
{
string val = (System.Environment.GetEnvironmentVariable(key) ?? string.Empty).ToLower();
string val = (Environment.GetEnvironmentVariable(key) ?? string.Empty).ToLower();
if (val == "1" || val == "true" || val == "yes" || val == "y" || val == "on") return true;
if (val == "0" || val == "false" || val == "no" || val == "n" || val == "off") return false;
return null;
Expand All @@ -44,14 +43,14 @@ public static string GetCleanEnvironmentVariable(string envvar, string badstring
public static uint GetAppId(string? appid)
{
uint.TryParse(appid, out var result);

// Will return 0 if appid is invalid (or zero).
return result;
}

public static string GetCType()
{
if (System.OperatingSystem.IsWindows())
if (OperatingSystem.IsWindows())
return "";
var psi = new ProcessStartInfo("sh");
psi.Arguments = "-c \"locale -a 2>/dev/null | grep -i utf\"";
Expand Down
19 changes: 2 additions & 17 deletions src/XIVLauncher.Core/LauncherApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public enum LauncherState
Loading,
OtpEntry,
Fts,
UpdateWarn,
SteamDeckPrompt,
}

Expand Down Expand Up @@ -82,10 +81,6 @@ public LauncherState State
this.ftsPage.OnShow();
break;

case LauncherState.UpdateWarn:
this.updateWarnPage.OnShow();
break;

case LauncherState.SteamDeckPrompt:
this.steamDeckPromptPage.OnShow();
break;
Expand All @@ -103,7 +98,6 @@ public LauncherState State
LauncherState.Loading => this.LoadingPage,
LauncherState.OtpEntry => this.otpEntryPage,
LauncherState.Fts => this.ftsPage,
LauncherState.UpdateWarn => this.updateWarnPage,
LauncherState.SteamDeckPrompt => this.steamDeckPromptPage,
_ => throw new ArgumentOutOfRangeException(nameof(this.state), this.state, null)
};
Expand All @@ -122,12 +116,11 @@ public LauncherState State
private readonly SettingsPage setPage;
private readonly OtpEntryPage otpEntryPage;
private readonly FtsPage ftsPage;
private readonly UpdateWarnPage updateWarnPage;
private readonly SteamDeckPromptPage steamDeckPromptPage;

private readonly Background background = new();

public LauncherApp(Storage storage, bool needsUpdateWarning, string frontierUrl, string? cutOffBootver)
public LauncherApp(Storage storage, string frontierUrl, string? cutOffBootver)
{
this.Storage = storage;

Expand All @@ -140,7 +133,6 @@ public LauncherApp(Storage storage, bool needsUpdateWarning, string frontierUrl,
this.otpEntryPage = new OtpEntryPage(this);
this.LoadingPage = new LoadingPage(this);
this.ftsPage = new FtsPage(this);
this.updateWarnPage = new UpdateWarnPage(this);
this.steamDeckPromptPage = new SteamDeckPromptPage(this);

if (!EnvironmentSettings.IsNoKillswitch && !string.IsNullOrEmpty(cutOffBootver))
Expand All @@ -158,14 +150,7 @@ public LauncherApp(Storage storage, bool needsUpdateWarning, string frontierUrl,
}
}

if (needsUpdateWarning)
{
this.State = LauncherState.UpdateWarn;
}
else
{
this.RunStartupTasks();
}
this.RunStartupTasks();

#if DEBUG
IsDebug = true;
Expand Down
2 changes: 1 addition & 1 deletion src/XIVLauncher.Core/LauncherClientConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace XIVLauncher.Core;
public readonly struct LauncherClientConfig
{
private const string LAUNCHER_CONFIG_URL = "https://kamori.goats.dev/Launcher/GetLauncherClientConfig";
private const string FRONTIER_FALLBACK = "https://launcher.finalfantasyxiv.com/v650/index.html?rc_lang={0}&time={1}";
private const string FRONTIER_FALLBACK = "https://launcher.finalfantasyxiv.com/v710/index.html?rc_lang={0}&time={1}";

public string frontierUrl { get; init; }
public string? cutOffBootver { get; init; }
Expand Down
20 changes: 3 additions & 17 deletions src/XIVLauncher.Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private static void Main(string[] args)
Loc.SetupWithFallbacks();

Dictionary<uint, string> apps = new Dictionary<uint, string>();
uint[] ignoredIds = { 0, STEAM_APP_ID, STEAM_APP_ID_FT};
uint[] ignoredIds = { 0, STEAM_APP_ID, STEAM_APP_ID_FT };
if (!ignoredIds.Contains(CoreEnvironmentSettings.SteamAppId))
{
apps.Add(CoreEnvironmentSettings.SteamAppId, "XLM");
Expand Down Expand Up @@ -294,22 +294,8 @@ private static void Main(string[] args)
StyleModelV1.DalamudStandard.Apply();
ImGui.GetIO().FontGlobalScale = Config.GlobalScale ?? 1.0f;

var needUpdate = false;

#if FLATPAK
if (Config.DoVersionCheck ?? false)
{
var versionCheckResult = UpdateCheck.CheckForUpdate().GetAwaiter().GetResult();

if (versionCheckResult.Success)
needUpdate = versionCheckResult.NeedUpdate;
}
#endif

needUpdate = CoreEnvironmentSettings.IsUpgrade ? true : needUpdate;

var launcherClientConfig = LauncherClientConfig.GetAsync().GetAwaiter().GetResult();
launcherApp = new LauncherApp(storage, needUpdate, launcherClientConfig.frontierUrl, launcherClientConfig.cutOffBootver);
launcherApp = new LauncherApp(storage, launcherClientConfig.frontierUrl, launcherClientConfig.cutOffBootver);

Invalidate(20);

Expand Down Expand Up @@ -370,7 +356,7 @@ private static void Main(string[] args)
if (Patcher is not null)
{
Patcher.CancelAllDownloads();
Task.Run(async() =>
Task.Run(async () =>
{
await PatchManager.UnInitializeAcquisition().ConfigureAwait(false);
Environment.Exit(0);
Expand Down
Binary file not shown.
42 changes: 0 additions & 42 deletions src/XIVLauncher.Core/UpdateCheck.cs

This file was deleted.

Loading

0 comments on commit bd5d622

Please sign in to comment.