Skip to content

Commit

Permalink
chore: some cleanup, refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Jul 6, 2022
1 parent af029cb commit a889bf6
Show file tree
Hide file tree
Showing 27 changed files with 195 additions and 185 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bugreport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ body:
id: terms
attributes:
label: Update disclaimer
description: If FFXIV recently updated, XIVLauncher and plugins will not work. They need to be updated first. You can get notified about updates on our Discord.
description: If the game recently updated, XIVLauncher and plugins will not work. They need to be updated first. You can get notified about updates on our Discord.
options:
- label: Yes, I have checked and my issue is not related to FFXIV updating and plugins not working correctly.
- label: Yes, I have checked and my issue is not related to the game updating and plugins not working correctly.
required: true
- type: textarea
id: what-happened
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ body:
id: terms
attributes:
label: Update disclaimer
description: If FFXIV recently updated, XIVLauncher and plugins will not work. They need to be updated first. You can get notified about updates on our Discord.
description: If the game recently updated, XIVLauncher and plugins will not work. They need to be updated first. You can get notified about updates on our Discord.
options:
- label: Yes, I have checked and my request is not related to FFXIV updating and plugins not working correctly.
- label: Yes, I have checked and my request is not related to the game updating and plugins not working correctly.
required: true
- type: textarea
id: what-happened
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Read in: [日本語](https://github.com/goatcorp/FFXIVQuickLauncher/wiki/Info-(Japanese)) | [Français](https://github.com/goatcorp/FFXIVQuickLauncher/wiki/Info-(French)) | [Deutsch](https://github.com/goatcorp/FFXIVQuickLauncher/wiki/Info-(German)) | [Español](https://github.com/goatcorp/FFXIVQuickLauncher/wiki/Info-(Spanish)) | [简体中文](https://github.com/goatcorp/FFXIVQuickLauncher/wiki/Info-(Chinese-Simplified)) | [繁體中文](https://github.com/goatcorp/FFXIVQuickLauncher/wiki/Info-(Chinese-Traditional)) | [한국어](https://github.com/goatcorp/FFXIVQuickLauncher/wiki/Info-(Korean)) | [Italiano](https://github.com/goatcorp/FFXIVQuickLauncher/wiki/Info-(Italian))

XIVLauncher (abbreviated as XL) is a faster launcher for FFXIV, with various available addons and enhancements to the game!
XIVLauncher (abbreviated as XL) is a faster launcher for our favorite critically acclaimed MMO, with various available addons and enhancements to the game!

<p align="center">
<a href="https://github.com/goatcorp/FFXIVQuickLauncher/releases">
Expand All @@ -12,7 +12,7 @@ XIVLauncher (abbreviated as XL) is a faster launcher for FFXIV, with various ava

## Why?

The original FFXIV launcher is slow and cannot save your password. This project aims to fix that and add some QoL features to the game, such as:
The original launcher is slow and cannot save your password. This project aims to fix that and add some QoL features to the game, such as:

* Auto-login
* Fast patching
Expand Down Expand Up @@ -70,6 +70,6 @@ We feel like that this offers developers the __freedom to improve the game's fun
<br>

## Disclaimer
XIVLauncher is not in-line with Square Enix ToS. We are doing our best to make it safe to use for everyone, and to our knowledge, no one ever got into trouble for using XIVLauncher, but please be aware that it is a possibility.<br>You can read through our [FAQ entry](https://goatcorp.github.io/faq/xl_troubleshooting#q-are-xivlauncher-dalamud-and-dalamud-plugins-safe-to-use) on this matter if you want to know more.
XIVLauncher is not in-line with the game's ToS. We are doing our best to make it safe to use for everyone, and to our knowledge, no one ever got into trouble for using XIVLauncher, but please be aware that it is a possibility.<br>You can read through our [FAQ entry](https://goatcorp.github.io/faq/xl_troubleshooting#q-are-xivlauncher-dalamud-and-dalamud-plugins-safe-to-use) on this matter if you want to know more.

##### FINAL FANTASY is a registered trademark of Square Enix Holdings Co., Ltd. FINAL FANTASY XIV © 2010-2022 SQUARE ENIX CO., LTD. All Rights Reserved. We are not affiliated with SQUARE ENIX CO., LTD. in any way.
2 changes: 1 addition & 1 deletion misc/linux_distrib/XIVLauncher.desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Desktop Entry]
Name=XIVLauncher
Comment=Custom launcher for Final Fantasy XIV Online
Comment=Custom launcher for the most critically acclaimed MMO
Exec=xivlauncher
Icon=xivlauncher
Terminal=false
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
<PackageReleaseNotes>Automated release</PackageReleaseNotes>
<Company>goatsoft</Company>
<Copyright>Copyright (c) goatsoft</Copyright>
<PackageTags>ffxiv</PackageTags>
<PackageTags>mmo</PackageTags>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public GameFixApply(DirectoryInfo gameDirectory, DirectoryInfo configDirectory,
{
this.fixes = new GameFix[]
{
new DefaultConfigGameFix(gameDirectory, configDirectory, winePrefixDirectory, tempDirectory),
new MacVideoFix(gameDirectory, configDirectory, winePrefixDirectory, tempDirectory),
};
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public override void Apply()

client.Download().GetAwaiter().GetResult();

var zipMovieFileNames = movieFileNames.Select(movie => Path.Combine("FINAL FANTASY XIV ONLINE.app", "Contents", "SharedSupport", "finalfantasyxiv", "support",
"published_Final_Fantasy", "drive_c", "Program Files (x86)", "SquareEnix", "FINAL FANTASY XIV - A Realm Reborn", "game", "movie", "ffxiv", movie));
var zipMovieFileNames = movieFileNames.Select(movie => Path.Combine("game", "movie", "ffxiv", movie));

using (ZipArchive archive = ZipFile.OpenRead(zipFilePath))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,6 @@ public static void Test()
};
var maxConcurrentConnectionsForPatchSet = 1;

// var baseDir = @"C:\Program Files (x86)\SquareEnix\FINAL FANTASY XIV - A Realm Reborn";
var baseDir = @"Z:\tgame";
var rootAndPatchPairs = new List<Tuple<string, string>>() {
Tuple.Create(@$"{baseDir}\boot", @"Z:\patch-dl.ffxiv.com\boot\2b5cbc63\D2021.11.16.0000.0001.patch.index"),
Expand Down
4 changes: 2 additions & 2 deletions src/XIVLauncher.Common/Util/GameHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public static bool IsRegionNorthAmerica()
return RegionInfo.CurrentRegion.TwoLetterISORegionName is "US" or "MX" or "CA";
}

public static bool IsValidFfxivPath(string path)
public static bool IsValidGamePath(string path)
{
if (string.IsNullOrEmpty(path))
return false;

return Directory.Exists(Path.Combine(path, "game")) && Directory.Exists(Path.Combine(path, "boot"));
}

public static bool CanFfxivMightNotBeInternationalClient(string path)
public static bool CanMightNotBeInternationalClient(string path)
{
if (Directory.Exists(Path.Combine(path, "sdo")))
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/XIVLauncher.Core/Components/MainPage/LoginFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public LoginFrame(MainPage mainPage)
{
this.mainPage = mainPage;

this.loginInput = new Input("Square Enix ID", "Enter your Square Enix ID", new Vector2(12f, 0f), 128);
this.loginInput = new Input("Username", "Enter your Username", new Vector2(12f, 0f), 128);
this.passwordInput = new Input("Password", "Enter your password", new Vector2(12f, 0f), 128, flags: ImGuiInputTextFlags.Password | ImGuiInputTextFlags.NoUndoRedo);

this.oneTimePasswordCheckbox = new Checkbox("Use one-time password");
Expand Down
15 changes: 0 additions & 15 deletions src/XIVLauncher.Core/Components/MainPage/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,28 +265,13 @@ private async Task<bool> TryProcessLoginResult(Launcher.LoginResult loginResult,
{
if (loginResult.State == Launcher.LoginState.NoService)
{
/*
CustomMessageBox.Show(
Loc.Localize("LoginNoServiceMessage",
"This Square Enix account cannot play FINAL FANTASY XIV. Please make sure that you have an active subscription and that it is paid up.\n\nIf you bought FINAL FANTASY XIV on Steam, make sure to check the \"Use Steam service account\" checkbox while logging in.\nIf Auto-Login is enabled, hold shift while starting to access settings."),
"Error",
MessageBoxButton.OK, MessageBoxImage.Error, showHelpLinks: false, showDiscordLink: false, parentWindow: _window);
*/

throw new Exception("No service account or subscription");

return false;
}

if (loginResult.State == Launcher.LoginState.NoTerms)
{
/*
CustomMessageBox.Show(
Loc.Localize("LoginAcceptTermsMessage",
"Please accept the FINAL FANTASY XIV Terms of Use in the official launcher."),
"Error", MessageBoxButton.OK, MessageBoxImage.Error, showOfficialLauncher: true, parentWindow: _window);
*/

throw new Exception("Need to accept terms of use");

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class SettingsTabGame : SettingsTab

new SettingsEntry<bool>("Use DirectX11", "Use the modern DirectX11 version of the game.", () => Program.Config.IsDx11 ?? true, x => Program.Config.IsDx11 = x)
{
CheckWarning = x => !x ? "DirectX 9 is no longer supported by Square Enix or Dalamud. Things may not work." : null
CheckWarning = x => !x ? "DirectX 9 is no longer supported by the game or Dalamud. Things may not work." : null
},

new SettingsEntry<string>("Additional Arguments", "Additional args to start the game with", () => Program.Config.AdditionalArgs, x => Program.Config.AdditionalArgs = x),
Expand Down
2 changes: 1 addition & 1 deletion src/XIVLauncher.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<projectUrl>https://github.com/goaaats/FFXIVQuickLauncher</projectUrl>
<iconUrl>https://raw.githubusercontent.com/goaaats/FFXIVQuickLauncher/master/XIVLauncher/Resources/dalamud_icon.ico</iconUrl>
<description>Custom launcher for FINAL FANTASY XIV</description>
<description>Custom launcher for the most critically acclaimed MMO</description>
</metadata>

<files>
Expand Down
43 changes: 40 additions & 3 deletions src/XIVLauncher/Accounts/XivAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace XIVLauncher.Accounts
{
public class XivAccount
{
private const string CREDS_PREFIX_OLD = "FINAL FANTASY XIV";
private const string CREDS_PREFIX_NEW = "XIVLAUNCHER";

[JsonIgnore]
public string Id => $"{UserName}-{UseOtp}-{UseSteamServiceAccount}";

Expand All @@ -23,22 +26,56 @@ public string Password
{
get
{
var credentials = CredentialManager.GetCredentials($"FINAL FANTASY XIV-{UserName.ToLower()}");
var credentials = CredentialManager.GetCredentials($"{CREDS_PREFIX_OLD}-{UserName.ToLower()}");

if (credentials != null)
{
var saved = CredentialManager.SaveCredentials($"{CREDS_PREFIX_NEW}-{UserName.ToLower()}", new NetworkCredential
{
UserName = credentials.UserName,
Password = credentials.Password,
});

if (saved)
{
try
{
CredentialManager.RemoveCredentials($"{CREDS_PREFIX_OLD}-{UserName.ToLower()}");
}
catch (Win32Exception)
{
// ignored
}
}
}
else
{
credentials = CredentialManager.GetCredentials($"{CREDS_PREFIX_NEW}-{UserName.ToLower()}");
}

return credentials != null ? credentials.Password : string.Empty;
}
set
{
try
{
CredentialManager.RemoveCredentials($"FINAL FANTASY XIV-{UserName.ToLower()}");
CredentialManager.RemoveCredentials($"{CREDS_PREFIX_OLD}-{UserName.ToLower()}");
}
catch (Win32Exception)
{
// ignored
}

try
{
CredentialManager.RemoveCredentials($"{CREDS_PREFIX_NEW}-{UserName.ToLower()}");
}
catch (Win32Exception)
{
// ignored
}

CredentialManager.SaveCredentials($"FINAL FANTASY XIV-{UserName.ToLower()}", new NetworkCredential
CredentialManager.SaveCredentials($"{CREDS_PREFIX_NEW}-{UserName.ToLower()}", new NetworkCredential
{
UserName = UserName,
Password = value
Expand Down
37 changes: 22 additions & 15 deletions src/XIVLauncher/AppUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ public static string GetFromResources(string resourceName)
return reader.ReadToEnd();
}

private static readonly string defaultPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "SquareEnix\\FINAL FANTASY XIV - A Realm Reborn");
private static string GetDefaultPath(string companyName, string gameName) => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), $"{companyName}\\{gameName}");

private static string[] GetCommonPaths()
private static string[] GetCommonPaths(string companyName1, string companyName2, string gameName, string rebootName)
{
var programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
var paths = new List<string>();
var drives = DriveInfo.GetDrives().Select(info => info.Name);

var commonPaths = new string[]
{
"Steam\\steamapps\\common\\FINAL FANTASY XIV Online",
"Steam\\steamapps\\common\\FINAL FANTASY XIV - A Realm Reborn",
"SquareEnix\\FINAL FANTASY XIV - A Realm Reborn",
"Square Enix\\FINAL FANTASY XIV - A Realm Reborn",
"Games\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn",
"Games\\Square Enix\\FINAL FANTASY XIV - A Realm Reborn",
$"Steam\\steamapps\\common\\{gameName} Online",
$"Steam\\steamapps\\common\\{gameName} - {rebootName}",
$"{companyName1}{companyName2}\\{gameName} - {rebootName}",
$"\\{gameName} - {rebootName}",
$"Games\\{companyName1}{companyName2}\\{gameName} - {rebootName}",
$"Games\\{companyName1} {companyName2}\\{gameName} - {rebootName}",
};

foreach (var commonPath in commonPaths)
Expand All @@ -79,7 +79,7 @@ private static string[] GetCommonPaths()
}
}

paths.Add(Path.Combine(programFiles, "FINAL FANTASY XIV - A Realm Reborn"));
paths.Add(Path.Combine(programFiles, $"{gameName} - {rebootName}"));

return paths.ToArray();
}
Expand All @@ -91,13 +91,20 @@ private static string[] GetCommonPaths()

public static string TryGamePaths()
{
const string CN_1 = "Square";
const string CN_2 = "Enix";
const string GN = "FINAL FANTASY XIV";
const string RN = "A Realm Reborn";

var defaultPath = GetDefaultPath($"{CN_1}{CN_2}", $"{GN} - {RN}");

try
{
var foundVersions = new Dictionary<string, SeVersion>();

foreach (var path in GetCommonPaths())
foreach (var path in GetCommonPaths(CN_1, CN_2, GN, RN))
{
if (!Directory.Exists(path) || !GameHelpers.IsValidFfxivPath(path) || foundVersions.ContainsKey(path))
if (!Directory.Exists(path) || !GameHelpers.IsValidGamePath(path) || foundVersions.ContainsKey(path))
continue;

var baseVersion = Repository.Ffxiv.GetVer(new DirectoryInfo(path));
Expand All @@ -108,30 +115,30 @@ public static string TryGamePaths()
{
using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, registryView))
{
// Should return "C:\Program Files (x86)\SquareEnix\FINAL FANTASY XIV - A Realm Reborn\boot\ffxivboot.exe" if installed with default options.
// Should return "C:\Program Files (x86)\company\game\boot\ffxivboot.exe" if installed with default options.
using (var subkey = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2B41E132-07DF-4925-A3D3-F2D1765CCDFE}"))
{
if (subkey != null && subkey.GetValue("DisplayIcon", null) is string path)
{
// DisplayIcon includes "boot\ffxivboot.exe", need to remove it
path = Directory.GetParent(path).Parent.FullName;

if (Directory.Exists(path) && GameHelpers.IsValidFfxivPath(path) && !foundVersions.ContainsKey(path))
if (Directory.Exists(path) && GameHelpers.IsValidGamePath(path) && !foundVersions.ContainsKey(path))
{
var baseVersion = Repository.Ffxiv.GetVer(new DirectoryInfo(path));
foundVersions.Add(path, SeVersion.Parse(baseVersion));
}
}
}

// Should return "C:\Program Files (x86)\Steam\steamapps\common\FINAL FANTASY XIV Online" if installed with default options.
// Should return "C:\Program Files (x86)\Steam\steamapps\common\game Online" if installed with default options.
foreach (var steamAppId in ValidSteamAppIds)
{
using (var subkey = hklm.OpenSubKey($@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App {steamAppId}"))
{
if (subkey != null && subkey.GetValue("InstallLocation", null) is string path)
{
if (Directory.Exists(path) && GameHelpers.IsValidFfxivPath(path) && !foundVersions.ContainsKey(path))
if (Directory.Exists(path) && GameHelpers.IsValidGamePath(path) && !foundVersions.ContainsKey(path))
{
// InstallLocation is the root path of the game (the one containing boot and game) itself
var baseVersion = Repository.Ffxiv.GetVer(new DirectoryInfo(path));
Expand Down
Loading

0 comments on commit a889bf6

Please sign in to comment.