Skip to content

Commit

Permalink
Fix Steam Auto-Launch, Simplify OTP Handling Using Configuration and …
Browse files Browse the repository at this point in the history
…Not Server / APK
  • Loading branch information
victormatuk committed Dec 3, 2024
1 parent 19c603d commit 0b2dfb9
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
<PackageReference Include="Otp.NET" Version="1.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/XIVLauncher.Common.Unix/XIVLauncher.Common.Unix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
<ItemGroup>
<!-- Custom steamworks, based on the chippy branch of Facepunch.Steamworks -->
<PackageReference Include="goaaats.Steamworks" Version="2.3.4" />
<PackageReference Include="Otp.NET" Version="1.4.0" />
</ItemGroup>
</Project>
5 changes: 3 additions & 2 deletions src/XIVLauncher.Common.Windows/WindowsSteam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace XIVLauncher.Common.Windows
{
public class WindowsSteam : ISteam
{
private const int MAX_INIT_TRIES_AFTER_START = 15;
//MATUK MOD BUG FIX
private const int MAX_INIT_TRIES_AFTER_START = 60;

public Task? AsyncStartTask { get; private set; }

Expand Down Expand Up @@ -172,4 +173,4 @@ public void ActivateGameOverlayToWebPage(string url, bool modal = false)

public event Action<bool> OnGamepadTextInputDismissed;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

<!-- Custom steamworks, based on the chippy branch of Facepunch.Steamworks -->
<PackageReference Include="goaaats.Steamworks" Version="2.3.4" />
<PackageReference Include="Otp.NET" Version="1.4.0" />
<PackageReference Include="PInvoke.Kernel32" Version="0.7.124" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions src/XIVLauncher.Common/XIVLauncher.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Downloader" Version="2.2.8" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Otp.NET" Version="1.4.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.Enrichers.Sensitive" Version="1.7.2" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Otp.NET" Version="1.4.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
Expand Down
6 changes: 5 additions & 1 deletion src/XIVLauncher/Settings/ILauncherSettingsV3.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using XIVLauncher.Common;
using XIVLauncher.Common.Addon;
Expand All @@ -16,6 +16,10 @@ public interface ILauncherSettingsV3
bool AutologinEnabled { get; set; }
List<AddonEntry> AddonList { get; set; }
bool UniqueIdCacheEnabled { get; set; }

//MATUK MOD
string OTPCodeConfig { get; set; }

string AdditionalLaunchArgs { get; set; }
bool InGameAddonEnabled { get; set; }
DalamudLoadMethod? InGameAddonLoadMethod { get; set; }
Expand Down
12 changes: 9 additions & 3 deletions src/XIVLauncher/Windows/SettingsControl.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="XIVLauncher.Windows.SettingsControl"
<UserControl x:Class="XIVLauncher.Windows.SettingsControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand All @@ -17,7 +17,7 @@
d:DataContext="{d:DesignInstance viewModel:SettingsControlViewModel}">
<Grid>
<dragablz:TabablzControl IsEnabled="True" FixedHeaderCount="7" x:Name="SetupTabControl"
Style="{StaticResource MaterialDesignTabablzControlStyle}">
Style="{StaticResource MaterialDesignTabablzControlStyle}" SelectionChanged="SetupTabControl_SelectionChanged">
<TabItem Header="{Binding SettingsGameLoc}">
<StackPanel Margin="10,10,0,0">
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top"
Expand All @@ -37,7 +37,13 @@
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top"
Foreground="Red" Text="{Binding GamePathSafeguardLoc}" x:Name="GamePathSafeguardText" Visibility="Collapsed"/>

<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBox Width="200" VerticalAlignment="Center"
HorizontalAlignment="Left" Foreground="{DynamicResource MaterialDesignBody}"
Margin="0,0,0,0" x:Name="OTPCodeConfig" materialDesign:HintAssist.Hint="Type your OTP code here" materialDesign:HintAssist.IsFloating="True"/>
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,15,0,0" Visibility="Collapsed">
<CheckBox Foreground="{DynamicResource MaterialDesignBody}"
x:Name="OtpServerCheckBox" Content="{Binding OtpServerCheckBoxLoc}" ToolTip="{Binding OtpServerTooltipLoc}"/>
<Button Style="{DynamicResource MaterialDesignFlatButton}"
Expand Down
15 changes: 14 additions & 1 deletion src/XIVLauncher/Windows/SettingsControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
Expand Down Expand Up @@ -77,6 +77,10 @@ public void ReloadSettings()

OtpServerCheckBox.IsChecked = App.Settings.OtpServerEnabled;

//MATUK MOD
OTPCodeConfig.Text = App.Settings.OTPCodeConfig;


LaunchArgsTextBox.Text = App.Settings.AdditionalLaunchArgs;

DpiAwarenessComboBox.SelectedIndex = (int) App.Settings.DpiAwareness.GetValueOrDefault(DpiAwareness.Unaware);
Expand Down Expand Up @@ -124,6 +128,10 @@ private void AcceptButton_Click(object sender, RoutedEventArgs e)
else
App.Settings.InGameAddonLoadMethod = DalamudLoadMethod.EntryPoint;

//MATUK
App.Settings.OTPCodeConfig = OTPCodeConfig.Text;


App.Settings.OtpServerEnabled = OtpServerCheckBox.IsChecked == true;

App.Settings.AdditionalLaunchArgs = LaunchArgsTextBox.Text;
Expand Down Expand Up @@ -433,5 +441,10 @@ private void OpenAdvancedSettings_OnClick(object sender, RoutedEventArgs e)
var asw = new AdvancedSettingsWindow();
asw.ShowDialog();
}

private void SetupTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{

}
}
}
10 changes: 8 additions & 2 deletions src/XIVLauncher/Windows/ViewModel/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Windows.Media;
using System.Windows.Threading;
using CheapLoc;
using OtpNet;
using Serilog;
using XIVLauncher.Accounts;
using XIVLauncher.Common;
Expand Down Expand Up @@ -273,8 +274,13 @@ private async Task Login(string username, string password, bool isOtp, bool isSt

var hasValidCache = App.UniqueIdCache.HasValidCache(username) && App.Settings.UniqueIdCacheEnabled;

var otp = string.Empty;
//MATUK MOD
string secret = App.Settings.OTPCodeConfig;
var secretKey = Base32Encoding.ToBytes(secret);
var totp = new Totp(secretKey);
var otp = totp.ComputeTotp();

/*var otp = string.Empty;
if (isOtp && (!hasValidCache || action == AfterLoginAction.Repair))
{
otp = OtpInputDialog.AskForOtp((otpDialog, result) =>
Expand All @@ -285,7 +291,7 @@ private async Task Login(string username, string password, bool isOtp, bool isSt
"This OTP has been already used.\nIt may take up to 30 seconds for a new one."));
}
}, _window);
}
}*/

if (otp == null)
return;
Expand Down
1 change: 1 addition & 0 deletions src/XIVLauncher/XIVLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<PackageReference Include="MaterialDesignThemes" Version="4.3.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.WindowsAPICodePack-Shell" Version="1.1.0" />
<PackageReference Include="Otp.NET" Version="1.4.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="1.0.1" />
Expand Down

0 comments on commit 0b2dfb9

Please sign in to comment.