From 9b6fbf715a38db6b7c01dce8b88641178fca0418 Mon Sep 17 00:00:00 2001
From: Silicasandwhich <43558271+Silicasandwhich@users.noreply.github.com>
Date: Thu, 29 Jun 2023 03:24:10 -0400
Subject: [PATCH 01/27] added drop down for additional launch options
---
src/XIVLauncher/App.xaml | 1 +
src/XIVLauncher/Windows/MainWindow.xaml | 48 ++++++++++++++++++-
.../Windows/ViewModel/MainWindowViewModel.cs | 1 +
3 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/src/XIVLauncher/App.xaml b/src/XIVLauncher/App.xaml
index 15a4fffbd..43152336a 100644
--- a/src/XIVLauncher/App.xaml
+++ b/src/XIVLauncher/App.xaml
@@ -16,6 +16,7 @@
+
diff --git a/src/XIVLauncher/Windows/MainWindow.xaml b/src/XIVLauncher/Windows/MainWindow.xaml
index 8bc9833e5..d47435447 100644
--- a/src/XIVLauncher/Windows/MainWindow.xaml
+++ b/src/XIVLauncher/Windows/MainWindow.xaml
@@ -279,11 +279,11 @@
+ Width="160" Margin="0,0,0,0" DockPanel.Dock="Bottom">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/XIVLauncher/Windows/MainWindow.xaml.cs b/src/XIVLauncher/Windows/MainWindow.xaml.cs
index 1c5c04d10..89420dafe 100644
--- a/src/XIVLauncher/Windows/MainWindow.xaml.cs
+++ b/src/XIVLauncher/Windows/MainWindow.xaml.cs
@@ -34,6 +34,7 @@ public partial class MainWindow : Window
{
private Timer _bannerChangeTimer;
private Headlines _headlines;
+ private IReadOnlyList _banners;
private BitmapImage[] _bannerBitmaps;
private int _currentBannerIndex;
private bool _everShown = false;
@@ -121,14 +122,20 @@ private async Task SetupHeadlines()
{
_bannerChangeTimer?.Stop();
- _headlines = await Headlines.Get(_launcher, App.Settings.Language.GetValueOrDefault(ClientLanguage.English), App.Settings.ForceNorthAmerica.GetValueOrDefault(false)).ConfigureAwait(false);
+ await Headlines.GetWorlds(_launcher, App.Settings.Language.GetValueOrDefault(ClientLanguage.English));
+ _banners = await Headlines.GetBanners(_launcher, App.Settings.Language.GetValueOrDefault(ClientLanguage.English), App.Settings.ForceNorthAmerica.GetValueOrDefault(false))
+ .ConfigureAwait(false);
+ await Headlines.GetMessage(_launcher, App.Settings.Language.GetValueOrDefault(ClientLanguage.English), App.Settings.ForceNorthAmerica.GetValueOrDefault(false))
+ .ConfigureAwait(false);
+ _headlines = await Headlines.GetNews(_launcher, App.Settings.Language.GetValueOrDefault(ClientLanguage.English), App.Settings.ForceNorthAmerica.GetValueOrDefault(false))
+ .ConfigureAwait(false);
- _bannerBitmaps = new BitmapImage[_headlines.Banner.Length];
+ _bannerBitmaps = new BitmapImage[_banners.Count];
_bannerDotList = new();
- for (var i = 0; i < _headlines.Banner.Length; i++)
+ for (var i = 0; i < _banners.Count; i++)
{
- var imageBytes = await _launcher.DownloadAsLauncher(_headlines.Banner[i].LsbBanner.ToString(), App.Settings.Language.GetValueOrDefault(ClientLanguage.English));
+ var imageBytes = await _launcher.DownloadAsLauncher(_banners[i].LsbBanner.ToString(), App.Settings.Language.GetValueOrDefault(ClientLanguage.English));
using var stream = new MemoryStream(imageBytes);
@@ -157,7 +164,7 @@ private async Task SetupHeadlines()
{
_bannerDotList.ToList().ForEach(x => x.Active = false);
- if (_currentBannerIndex + 1 > _headlines.Banner.Length - 1)
+ if (_currentBannerIndex + 1 > _banners.Count - 1)
_currentBannerIndex = 0;
else
_currentBannerIndex++;
@@ -176,8 +183,9 @@ private async Task SetupHeadlines()
Dispatcher.BeginInvoke(new Action(() => { NewsListView.ItemsSource = _headlines.News; }));
}
- catch (Exception)
+ catch (Exception ex)
{
+ Log.Error(ex, "Could not get news");
Dispatcher.BeginInvoke(new Action(() =>
{
NewsListView.ItemsSource = new List {new News {Title = Loc.Localize("NewsDlFailed", "Could not download news data."), Tag = "DlError"}};
@@ -272,23 +280,6 @@ public void Initialize()
this.SetDefaults();
- var worldStatusBrushOk = WorldStatusPackIcon.Foreground;
- // grey out world status icon while deferred check is running
- WorldStatusPackIcon.Foreground = new SolidColorBrush(Color.FromRgb(38, 38, 38));
-
- _launcher.GetGateStatus(App.Settings.Language.GetValueOrDefault(ClientLanguage.English)).ContinueWith((resultTask) =>
- {
- try
- {
- var brushToSet = resultTask.Result.Status ? worldStatusBrushOk : null;
- Dispatcher.InvokeAsync(() => WorldStatusPackIcon.Foreground = brushToSet ?? new SolidColorBrush(Color.FromRgb(242, 24, 24)));
- }
- catch
- {
- // ignored
- }
- });
-
_accountManager = new AccountManager(App.Settings);
var savedAccount = _accountManager.CurrentAccount;
@@ -359,7 +350,7 @@ private void BannerCard_MouseUp(object sender, MouseButtonEventArgs e)
if (e.ChangedButton != MouseButton.Left)
return;
- if (_headlines != null) Process.Start(_headlines.Banner[_currentBannerIndex].Link.ToString());
+ if (_headlines != null) Process.Start(_banners[_currentBannerIndex].Link.ToString());
}
private void NewsListView_OnMouseUp(object sender, MouseButtonEventArgs e)
diff --git a/src/XIVLauncher/Windows/ViewModel/MainWindowViewModel.cs b/src/XIVLauncher/Windows/ViewModel/MainWindowViewModel.cs
index 523eef882..e347b7e18 100644
--- a/src/XIVLauncher/Windows/ViewModel/MainWindowViewModel.cs
+++ b/src/XIVLauncher/Windows/ViewModel/MainWindowViewModel.cs
@@ -10,6 +10,7 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
+using System.Windows.Media;
using System.Windows.Threading;
using CheapLoc;
using Serilog;
@@ -36,6 +37,9 @@ internal class MainWindowViewModel : INotifyPropertyChanged
{
private readonly Window _window;
+ private readonly Task loginStatusTask;
+ private bool refetchLoginStatus = false;
+
public bool IsLoggingIn;
public Launcher Launcher { get; private set; }
@@ -71,9 +75,36 @@ public MainWindowViewModel(Window window)
LoginNoThirdCommand = new SyncCommand(GetLoginFunc(AfterLoginAction.StartWithoutThird), () => !IsLoggingIn);
LoginRepairCommand = new SyncCommand(GetLoginFunc(AfterLoginAction.Repair), () => !IsLoggingIn);
+ var frontierUrl = Updates.UpdateLease?.FrontierUrl;
+#if DEBUG || RELEASENOUPDATE
+ // FALLBACK
+ frontierUrl ??= "https://launcher.finalfantasyxiv.com/v650/index.html?rc_lang={0}&time={1}";
+#endif
+
Launcher = App.GlobalSteamTicket == null
- ? new(App.Steam, App.UniqueIdCache, CommonSettings.Instance, Updates.UpdateLease?.FrontierUrl)
- : new(App.GlobalSteamTicket, App.UniqueIdCache, CommonSettings.Instance, Updates.UpdateLease?.FrontierUrl);
+ ? new(App.Steam, App.UniqueIdCache, CommonSettings.Instance, frontierUrl)
+ : new(App.GlobalSteamTicket, App.UniqueIdCache, CommonSettings.Instance, frontierUrl);
+
+ // Tried and failed to get this from the theme
+ var worldStatusBrushOk = new SolidColorBrush(Color.FromRgb(0x21, 0x96, 0xf3));
+ WorldStatusIconColor = worldStatusBrushOk;
+
+ // Grey out world status icon while deferred check is running
+ WorldStatusIconColor = new SolidColorBrush(Color.FromRgb(38, 38, 38));
+
+ this.loginStatusTask = Launcher.GetLoginStatus();
+ this.loginStatusTask.ContinueWith((resultTask) =>
+ {
+ try
+ {
+ var brushToSet = resultTask.Result.Status ? worldStatusBrushOk : null;
+ WorldStatusIconColor = brushToSet ?? new SolidColorBrush(Color.FromRgb(242, 24, 24));
+ }
+ catch
+ {
+ // ignored
+ }
+ });
}
private Action