Skip to content

Commit a9ecfed

Browse files
committed
feat: Free Trial mode checkbox for Steam
1 parent 9e77a5c commit a9ecfed

14 files changed

+32
-16
lines changed

src/XIVLauncher.Common/Constants.cs

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ public static class Constants
66
{
77
public const string BASE_GAME_VERSION = "2012.01.01.0000.0000";
88

9+
public const uint STEAM_APP_ID = 39210;
10+
public const uint STEAM_FT_APP_ID = 312060;
11+
912
public static string PatcherUserAgent => GetPatcherUserAgent(Util.GetPlatform());
1013

1114
private static string GetPatcherUserAgent(Platform platform)

src/XIVLauncher.Common/Dalamud/AssetManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static bool TryEnsureAssets(DirectoryInfo baseDir, out DirectoryInfo asse
8888

8989
try
9090
{
91-
File.Copy(filePath, filePathDev);
91+
File.Copy(filePath, filePathDev, true);
9292
}
9393
catch
9494
{

src/XIVLauncher.Common/Game/Launcher.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ public Launcher(ISteam steam, IUniqueIdCache uniqueIdCache, ISettings settings)
4141
private const string USER_AGENT_TEMPLATE = "SQEXAuthor/2.0.0(Windows 6.2; ja-jp; {0})";
4242
private readonly string _userAgent = GenerateUserAgent();
4343

44-
public const int STEAM_APP_ID = 39210;
45-
4644
private static readonly string[] FilesToHash =
4745
{
4846
"ffxivboot.exe",
@@ -71,7 +69,7 @@ public class LoginResult
7169
public string UniqueId { get; set; }
7270
}
7371

74-
public async Task<LoginResult> Login(string userName, string password, string otp, bool isSteamServiceAccount, bool useCache, DirectoryInfo gamePath, bool forceBaseVersion)
72+
public async Task<LoginResult> Login(string userName, string password, string otp, bool isSteamServiceAccount, bool useCache, DirectoryInfo gamePath, bool forceBaseVersion, bool isFt)
7573
{
7674
string uid;
7775
PatchListEntry[] pendingPatches = null;
@@ -90,7 +88,7 @@ public async Task<LoginResult> Login(string userName, string password, string ot
9088
{
9189
if (!this.steam.IsValid)
9290
{
93-
this.steam.Initialize(STEAM_APP_ID);
91+
this.steam.Initialize(isFt ? Constants.STEAM_FT_APP_ID : Constants.STEAM_APP_ID);
9492
}
9593
}
9694
catch (Exception ex)

src/XIVLauncher.Common/Util.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ public static long GetUnixMillis()
6464
return (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;
6565
}
6666

67+
public static FileInfo GetOfficialLauncherPath(DirectoryInfo gamePath) => new(Path.Combine(gamePath.FullName, "boot", "ffxivboot.exe"));
68+
6769
public static void StartOfficialLauncher(DirectoryInfo gamePath, bool isSteam)
6870
{
69-
Process.Start(Path.Combine(gamePath.FullName, "boot", "ffxivboot.exe"), isSteam ? "-issteam" : string.Empty);
71+
Process.Start(GetOfficialLauncherPath(gamePath).FullName, isSteam ? "-issteam" : string.Empty);
7072
}
7173

7274
public static string BytesToString(double byteCount) => BytesToString(Convert.ToInt64(Math.Floor(byteCount)));

src/XIVLauncher.Core/Components/MainPage/MainPage.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public async Task Login(string username, string password, bool isOtp, bool isSte
6363
if (otp == null)
6464
return;
6565

66-
var loginResult = await Program.Launcher.Login(username, password, otp, isSteam, true, Program.Config.GamePath, false).ConfigureAwait(true);
66+
var loginResult = await Program.Launcher.Login(username, password, otp, isSteam, true, Program.Config.GamePath, false, false).ConfigureAwait(true);
6767

6868
if (loginResult.State != Launcher.LoginState.Ok)
6969
{

src/XIVLauncher/Settings/ILauncherSettingsV3.cs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public interface ILauncherSettingsV3
3939
int? VersionUpgradeLevel { get; set; }
4040
bool? TreatNonZeroExitCodeAsFailure { get; set; }
4141
bool? ExitLauncherAfterGameExit { get; set; }
42+
bool? IsFt { get; set; }
4243

4344
#endregion
4445
}

src/XIVLauncher/Windows/CustomMessageBox.xaml.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
using MaterialDesignThemes.Wpf;
1313
using Serilog;
1414
using XIVLauncher.Common;
15-
using XIVLauncher.Common.Game;
1615
using XIVLauncher.Support;
1716
using XIVLauncher.Windows.ViewModel;
1817
using XIVLauncher.Xaml;
18+
using Constants = XIVLauncher.Common.Constants;
1919

2020
namespace XIVLauncher.Windows
2121
{
@@ -195,6 +195,12 @@ private void Button3_Click(object sender, RoutedEventArgs e)
195195

196196
private void OfficialLauncherButton_Click(object sender, RoutedEventArgs e)
197197
{
198+
if (!Util.GetOfficialLauncherPath(App.Settings.GamePath).Exists)
199+
{
200+
CustomMessageBox.Show(Loc.Localize("RunOfficialLauncherNotPresentError", "You don't have a FFXIV game installation set up. XIVLauncher can't start the official launcher."), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
201+
return;
202+
}
203+
198204
switch (Builder
199205
.NewFrom(Loc.Localize("RunOfficialLauncherConfirmSteam", "Do you have your game account associated with a Steam account? If so, Steam must be installed to continue."))
200206
.WithImage(MessageBoxImage.Question)
@@ -208,7 +214,7 @@ private void OfficialLauncherButton_Click(object sender, RoutedEventArgs e)
208214
{
209215
if (!steam.IsValid)
210216
{
211-
steam.Initialize(Launcher.STEAM_APP_ID);
217+
steam.Initialize(App.Settings.IsFt.GetValueOrDefault(false) ? Constants.STEAM_FT_APP_ID : Constants.STEAM_APP_ID);
212218
}
213219

214220
Thread.Sleep(5000);

src/XIVLauncher/Windows/MainWindow.xaml.cs

+2
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ private void SetDefaults()
185185
App.Settings.TreatNonZeroExitCodeAsFailure ??= false;
186186
App.Settings.ExitLauncherAfterGameExit ??= true;
187187

188+
App.Settings.IsFt ??= false;
189+
188190
var versionLevel = App.Settings.VersionUpgradeLevel.GetValueOrDefault(0);
189191

190192
while (versionLevel < CURRENT_VERSION_LEVEL)

src/XIVLauncher/Windows/SettingsControl.xaml

+3
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@
338338
<CheckBox x:Name="TreatNonZeroExitCodeAsFailureCheckbox"
339339
Content="{Binding TreatNonZeroExitCodeAsFailureLoc}"
340340
HorizontalAlignment="Left" Margin="0,0,0,7" Foreground="DarkGray" />
341+
<CheckBox x:Name="IsFreeTrialCheckbox"
342+
Content="{Binding IsFreeTrialLoc}"
343+
HorizontalAlignment="Left" Margin="0,0,0,7" Foreground="DarkGray" />
341344
</StackPanel>
342345

343346
<Image Source="pack://application:,,,/Resources/logo.png" Width="200"

src/XIVLauncher/Windows/SettingsControl.xaml.cs

+4
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public void ReloadSettings()
100100
var val = (decimal) App.Settings.SpeedLimitBytes / BYTES_TO_MB;
101101

102102
SpeedLimiterUpDown.Value = val;
103+
104+
IsFreeTrialCheckbox.IsChecked = App.Settings.IsFt;
103105
}
104106

105107
private void AcceptButton_Click(object sender, RoutedEventArgs e)
@@ -150,6 +152,8 @@ private void AcceptButton_Click(object sender, RoutedEventArgs e)
150152

151153
App.Settings.SpeedLimitBytes = (long) (SpeedLimiterUpDown.Value * BYTES_TO_MB);
152154

155+
App.Settings.IsFt = this.IsFreeTrialCheckbox.IsChecked == true;
156+
153157
Transitioner.MoveNextCommand.Execute(null, null);
154158
}
155159

src/XIVLauncher/Windows/ViewModel/MainWindowViewModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ private void ShowInternetError()
301301
var gamePath = App.Settings.GamePath;
302302

303303
if (action == AfterLoginAction.Repair)
304-
return await this.Launcher.Login(username, password, otp, isSteam, false, gamePath, true);
304+
return await this.Launcher.Login(username, password, otp, isSteam, false, gamePath, true, App.Settings.IsFt.GetValueOrDefault(false));
305305
else
306-
return await this.Launcher.Login(username, password, otp, isSteam, enableUidCache, gamePath, false);
306+
return await this.Launcher.Login(username, password, otp, isSteam, enableUidCache, gamePath, false, App.Settings.IsFt.GetValueOrDefault(false));
307307
}
308308
catch (Exception ex)
309309
{

src/XIVLauncher/Windows/ViewModel/SettingsControlViewModel.cs

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ private void SetupLoc()
157157
EnableEncryptionLoc = Loc.Localize("EnableEncryption", "Enable encrypting arguments to the client");
158158
ExitLauncherAfterGameExitLoc = Loc.Localize("ExitLauncherAfterGameExitLoc", "Exit XIVLauncher after game exit");
159159
TreatNonZeroExitCodeAsFailureLoc = Loc.Localize("TreatNonZeroExitCodeAsFailureLoc", "Treat non-zero game exit code as failure");
160+
IsFreeTrialLoc = Loc.Localize("IsFreeTrial", "Start in free trial mode");
160161
}
161162

162163
public string OpenPluginsFolderLoc { get; private set; }
@@ -236,5 +237,6 @@ private void SetupLoc()
236237
public string EnableEncryptionLoc { get; private set; }
237238
public string ExitLauncherAfterGameExitLoc { get; private set; }
238239
public string TreatNonZeroExitCodeAsFailureLoc { get; private set; }
240+
public string IsFreeTrialLoc { get; private set; }
239241
}
240242
}

src/XIVLauncher/XIVLauncher.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
<Resource Remove="Resources\CHANGELOG.txt" />
5353
<Resource Remove="Resources\COPYING.aria2" />
5454
<Resource Remove="Resources\LICENSE.txt" />
55-
<None Remove="steam_appid.txt" />
5655
</ItemGroup>
5756

5857
<ItemGroup>
@@ -68,9 +67,6 @@
6867
<Content Include="Resources\LICENSE.txt">
6968
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
7069
</Content>
71-
<Content Include="steam_appid.txt">
72-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
73-
</Content>
7470
</ItemGroup>
7571

7672
<ItemGroup>

src/XIVLauncher/steam_appid.txt

-1
This file was deleted.

0 commit comments

Comments
 (0)