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

Update frontier URL and fix news handling. #96

Merged
merged 1 commit into from
Nov 18, 2023
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
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
Loading