Skip to content

Commit

Permalink
Merge pull request #96 from rankynbass/frontier-quickfix
Browse files Browse the repository at this point in the history
Update frontier URL and fix news handling.
  • Loading branch information
marzent authored Nov 18, 2023
2 parents 607a4e5 + 34bec31 commit dfbc483
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
19 changes: 14 additions & 5 deletions src/XIVLauncher.Core/Components/MainPage/NewsFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class NewsFrame : Component
private Headlines? headlines;
private TextureWrap[]? banners;

private IReadOnlyList<Banner>? bannerList;

private int currentBanner = 0;

private bool newsLoaded = false;
Expand Down Expand Up @@ -43,14 +45,21 @@ public void ReloadNews()
{
this.newsLoaded = false;
this.headlines = await Headlines.Get(this.app.Launcher, this.app.Settings.ClientLanguage ?? ClientLanguage.English).ConfigureAwait(false);
this.banners = new TextureWrap[this.headlines.Banner.Length];
await Headlines.GetWorlds(this.app.Launcher, this.app.Settings.ClientLanguage ?? ClientLanguage.English);
bannerList = await Headlines.GetBanners(this.app.Launcher, this.app.Settings.ClientLanguage ?? ClientLanguage.English).ConfigureAwait(false);
await Headlines.GetMessage(this.app.Launcher, this.app.Settings.ClientLanguage ?? ClientLanguage.English);
headlines = await Headlines.GetNews(this.app.Launcher, this.app.Settings.ClientLanguage ?? ClientLanguage.English).ConfigureAwait(false);
this.banners = new TextureWrap[bannerList.Count];
var client = new HttpClient();
for (var i = 0; i < this.headlines.Banner.Length; i++)
for (var i = 0; i < bannerList.Count; i++)
{
var textureBytes = await client.GetByteArrayAsync(this.headlines.Banner[i].LsbBanner).ConfigureAwait(false);
var textureBytes = await client.GetByteArrayAsync(this.bannerList[i].LsbBanner).ConfigureAwait(false);
this.banners[i] = TextureWrap.Load(textureBytes);
}
Expand All @@ -77,7 +86,7 @@ public override void Draw()
ImGui.Image(banner.ImGuiHandle, banner.Size);

if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
AppUtil.OpenBrowser(this.headlines.Banner[this.currentBanner].Link.ToString());
AppUtil.OpenBrowser(this.bannerList[this.currentBanner].Link.ToString());

ImGui.Dummy(new Vector2(15));

Expand Down
4 changes: 2 additions & 2 deletions src/XIVLauncher.Core/LauncherApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ public LauncherState State

private readonly Background background = new();

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

this.Accounts = new AccountManager(this.Storage.GetFile("accounts.json"));
this.UniqueIdCache = new CommonUniqueIdCache(this.Storage.GetFile("uidCache.json"));
this.Launcher = new Launcher(Program.Steam, UniqueIdCache, Program.CommonSettings);
this.Launcher = new Launcher(Program.Steam, UniqueIdCache, Program.CommonSettings, frontierUrl);

this.mainPage = new MainPage(this);
this.setPage = new SettingsPage(this);
Expand Down
4 changes: 3 additions & 1 deletion src/XIVLauncher.Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class Program
private static uint invalidationFrames = 0;
private static Vector2 lastMousePosition;

private const string FRONTIER_FALLBACK = "https://launcher.finalfantasyxiv.com/v650/index.html?rc_lang={0}&time={1}";

public static void Invalidate(uint frames = 100)
{
invalidationFrames = frames;
Expand Down Expand Up @@ -258,7 +260,7 @@ private static void Main(string[] args)

needUpdate = CoreEnvironmentSettings.IsUpgrade ? true : needUpdate;

launcherApp = new LauncherApp(storage, needUpdate);
launcherApp = new LauncherApp(storage, needUpdate, FRONTIER_FALLBACK);

Invalidate(20);

Expand Down

0 comments on commit dfbc483

Please sign in to comment.