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

Steam Compatibility Tool installer #99

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
da6333b
feature: Allow install as Steam compatibility tool
rankynbass Nov 24, 2023
34c396d
Tweak Steam Tool tab for clearer instructions
rankynbass Nov 25, 2023
0084586
Add uninstall buttons
rankynbass Nov 25, 2023
08d2cb3
Fix compatibility tool launch script, clean up instructions.
rankynbass Nov 25, 2023
98d8cb1
Ignore Steam won't be used with Steam compat tool
rankynbass Nov 25, 2023
1e0f80b
Add 1s sleep to xlcore script.
rankynbass Nov 26, 2023
f373482
Add checks for steam
rankynbass Nov 26, 2023
1ca0695
Fix non-flatpak Steam detection in flatpak
rankynbass Nov 27, 2023
2e2569a
Removed #if FLATPAK directives
rankynbass Nov 28, 2023
0ea02dc
Allow --install to handle ~/path/to/Steam
rankynbass Nov 28, 2023
8d6a079
Rework XL_PRELOAD
rankynbass Dec 16, 2023
abc6e2e
Merge branch 'main' into sct-installer
rankynbass Mar 14, 2024
4d8d9b8
Minor script fix. Seems to help with stuttering.
rankynbass Mar 23, 2024
cb12b7a
Deck doesn't show flatpak install option
rankynbass Mar 23, 2024
9cb5a1a
Change some wording per suggestions
rankynbass Mar 27, 2024
d6d4e44
Fix some spacing issues
rankynbass Mar 27, 2024
f7f0f70
Merge branch 'main' into sct-installer
rankynbass Mar 27, 2024
b8fee9c
Convert xlcore script to posix sh
rankynbass Apr 6, 2024
e6001c2
Update otp with Common components
rankynbass Apr 7, 2024
62c16da
Try without extra Steam Input
rankynbass Apr 7, 2024
e03cd9b
Update with better steamdeck detection
rankynbass Apr 13, 2024
c3098ab
Improve CL options
rankynbass Apr 19, 2024
17b0509
Show flatpak steam instructions for all non-steamdeck users
rankynbass May 23, 2024
2357bdd
Improve handling of different versions
rankynbass May 23, 2024
0eebea8
Use Program.CoreRelease in SteamCompatibilityTool.cs
rankynbass May 23, 2024
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
6 changes: 4 additions & 2 deletions src/XIVLauncher.Core/Components/Common/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class Button : Component

public int? Width { get; set; }

public int? Height { get; set; }

public Button(string label, bool isEnabled = true, Vector4? color = null, Vector4? hoverColor = null, Vector4? textColor = null)
{
Label = label;
Expand All @@ -28,13 +30,13 @@ public Button(string label, bool isEnabled = true, Vector4? color = null, Vector

public override void Draw()
{
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(16f, 16f));
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(Width is not null ? 0f : 16f, Height is not null ? 0f : 16f));
ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0);
ImGui.PushStyleColor(ImGuiCol.Button, Color);
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, HoverColor);
ImGui.PushStyleColor(ImGuiCol.Text, TextColor);

if (ImGui.Button(Label, new Vector2(Width ?? -1, 0)) || (ImGui.IsItemFocused() && ImGui.IsKeyPressed(ImGuiKey.Enter)))
if (ImGui.Button(Label, new Vector2(Width ?? -1, Height ?? 0)) || (ImGui.IsItemFocused() && (ImGui.IsKeyPressed(ImGuiKey.Enter) || ImGui.IsKeyPressed(ImGuiKey.KeypadEnter))))
{
this.Click?.Invoke();
}
Expand Down
33 changes: 29 additions & 4 deletions src/XIVLauncher.Core/Components/Common/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class Input : Component

public uint MaxLength { get; }

public int Width { get; set; }

public ImGuiInputTextFlags Flags { get; }

public bool IsEnabled { get; set; } = true;
Expand All @@ -32,6 +34,8 @@ public class Input : Component
/** Executed on detection of the enter key **/
public event Action? Enter;

public event Action? Escape;

public string Value
{
get => inputBacking;
Expand All @@ -43,12 +47,14 @@ public Input(
string hint,
Vector2? spacing,
uint maxLength = 255,
int width = 0,
bool isEnabled = true,
ImGuiInputTextFlags flags = ImGuiInputTextFlags.None)
{
Label = label;
Hint = hint;
MaxLength = maxLength;
Width = width;
Flags = flags;
IsEnabled = isEnabled;
Spacing = spacing ?? Vector2.Zero;
Expand All @@ -58,7 +64,7 @@ public Input(
if (Program.Steam != null)
{
Program.Steam.OnGamepadTextInputDismissed += this.SteamOnOnGamepadTextInputDismissed;
HasSteamDeckInput = Program.IsSteamDeckHardware;
HasSteamDeckInput = Program.IsSteamDeckGamingMode;
}
}

Expand All @@ -83,23 +89,42 @@ public override void Draw()
if (TakeKeyboardFocus && ImGui.IsWindowAppearing())
ImGui.SetKeyboardFocusHere();

ImGui.Text(Label);
if (!string.IsNullOrEmpty(Label))
{
if (Width != 0)
ImGuiHelpers.CenteredText(Label);
else
ImGui.Text(Label);
}

if (!this.IsEnabled || this.isSteamDeckInputActive)
ImGui.BeginDisabled();

var ww = ImGui.GetWindowWidth();
ImGui.SetNextItemWidth(ww);
if (Width != 0 && Width <= ww)
{
ImGui.SetNextItemWidth(Width);
ImGuiHelpers.CenterCursorFor(Width);
}
else
{
ImGui.SetNextItemWidth(ww);
}

ImGui.PopStyleColor();

ImGui.InputTextWithHint($"###{Id}", Hint, ref inputBacking, MaxLength, Flags);

if (ImGui.IsItemFocused() && ImGui.IsKeyPressed(ImGuiKey.Enter))
if (ImGui.IsItemFocused() && (ImGui.IsKeyPressed(ImGuiKey.Enter) || ImGui.IsKeyPressed(ImGuiKey.KeypadEnter)))
{
Enter?.Invoke();
}

if (ImGui.IsItemFocused() && ImGui.IsKeyPressed(ImGuiKey.Escape))
{
Escape?.Invoke();
}

if (ImGui.IsItemActivated() && HasSteamDeckInput && Program.Steam != null && Program.Steam.IsValid)
{
this.isSteamDeckInputActive = Program.Steam?.ShowGamepadTextInput(Flags.HasFlag(ImGuiInputTextFlags.Password), false, SteamDeckPrompt, (int)MaxLength, this.inputBacking) ?? false;
Expand Down
5 changes: 5 additions & 0 deletions src/XIVLauncher.Core/Components/MainPage/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,11 @@ public async Task<Process> StartGameAndAddon(Launcher.LoginResult loginResult, b

IGameRunner runner;

// Set LD_PRELOAD to value of XL_PRELOAD if we're in Steam Compatibility Tool mode.
// We ONLY care about XL_PRELOAD if we're in SCT mode. It's a workaround to prevent a text bug with Steam overlay enabled.
if (CoreEnvironmentSettings.IsSteamCompatTool)
System.Environment.SetEnvironmentVariable("LD_PRELOAD", CoreEnvironmentSettings.GetCleanEnvironmentVariable("XL_PRELOAD"));

// Hack: Force C.utf8 to fix incorrect unicode paths
if (App.Settings.FixLocale == true && !string.IsNullOrEmpty(Program.CType))
{
Expand Down
95 changes: 71 additions & 24 deletions src/XIVLauncher.Core/Components/OtpEntryPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

using XIVLauncher.Common.Http;

using XIVLauncher.Core.Components.Common;

namespace XIVLauncher.Core.Components;

public class OtpEntryPage : Page
Expand All @@ -19,20 +21,55 @@ public class OtpEntryPage : Page

private OtpListener? otpListener;

public OtpEntryPage(LauncherApp app)
: base(app)
private Input otpInput;

private Button otpOKButton;

private Button otpCancelButton;

public string otpValue
{
if (Program.Steam is not null) Program.Steam.OnGamepadTextInputDismissed += this.SteamOnOnGamepadTextInputDismissed;
get => this.otpInput.Value;
set => this.otpInput.Value = value;
}

private void SteamOnOnGamepadTextInputDismissed(bool success)
public OtpEntryPage(LauncherApp app)
: base(app)
{
if (success)
void getOtp()
{
TryAcceptOtp(this.otpValue);
}

void cancelOtp()
{
if (Program.Steam is not null) Result = Program.Steam.GetEnteredGamepadText();
this.Cancelled = true;
}

// if (Program.Steam is not null) Program.Steam.OnGamepadTextInputDismissed += this.SteamOnOnGamepadTextInputDismissed;

this.otpInput = new Input("", "", new Vector2(12f, 0f), 6, 150, flags: ImGuiInputTextFlags.CharsDecimal)
{
TakeKeyboardFocus = true
};
this.otpInput.Enter += getOtp;
this.otpInput.Escape += cancelOtp;

this.otpOKButton = new Button("OK");
this.otpOKButton.Click += getOtp;

this.otpCancelButton = new Button("Cancel");
this.otpCancelButton.Click += cancelOtp;
}

// private void SteamOnOnGamepadTextInputDismissed(bool success)
// {
// if (success)
// {
// if (Program.Steam is not null) Result = Program.Steam.GetEnteredGamepadText();
// }
// }

public void Reset()
{
this.otp = string.Empty;
Expand All @@ -42,11 +79,11 @@ public void Reset()

// TODO(goat): This doesn't work if you call it right after starting the app... Steam probably takes a little while to initialize. Might be annoying for autologin.
// BUG: We have to turn this off when using OTP server, because there's no way to dismiss open keyboards
if (Program.Steam != null && Program.Steam.IsValid && Program.IsSteamDeckHardware && App.Settings.IsOtpServer is false)
{
var success = Program.Steam.ShowGamepadTextInput(false, false, "Please enter your OTP", 6, string.Empty);
Log.Verbose("ShowGamepadTextInput: {Success}", success);
}
// if (Program.Steam != null && Program.Steam.IsValid && Program.IsSteamDeckHardware && App.Settings.IsOtpServer is false)
// {
// var success = Program.Steam.ShowGamepadTextInput(false, false, "Please enter your OTP", 6, string.Empty);
// Log.Verbose("ShowGamepadTextInput: {Success}", success);
// }

if (App.Settings.IsOtpServer ?? false)
{
Expand Down Expand Up @@ -90,37 +127,47 @@ public override void Draw()

if (ImGui.BeginChild("###otp", childSize, true, ImGuiWindowFlags.AlwaysAutoResize))
{
ImGui.Dummy(new Vector2(40));
ImGui.Dummy(new Vector2(30));

// center text in window
ImGuiHelpers.CenteredText("Please enter your OTP");

const int INPUT_WIDTH = 150;
ImGui.SetNextItemWidth(INPUT_WIDTH);
ImGuiHelpers.CenterCursorFor(INPUT_WIDTH);

if (this.appearing)
{
ImGui.SetKeyboardFocusHere(0);
this.appearing = false;
}

var doEnter = ImGui.InputText("###otpInput", ref this.otp, 6, ImGuiInputTextFlags.CharsDecimal | ImGuiInputTextFlags.EnterReturnsTrue);
//var doEnter = ImGui.InputText("###otpInput", ref this.otp, 6, ImGuiInputTextFlags.CharsDecimal | ImGuiInputTextFlags.EnterReturnsTrue);
otpInput.Width = INPUT_WIDTH;
otpInput.Draw();

var buttonSize = new Vector2(INPUT_WIDTH / 2 - 4, 30);
// var buttonSize = new Vector2(INPUT_WIDTH / 2 - 4, 30);
int buttonW = INPUT_WIDTH / 2 - 4;
int buttonH = 40;
ImGuiHelpers.CenterCursorFor(INPUT_WIDTH);

if (ImGui.Button("OK", buttonSize) || doEnter)
{
TryAcceptOtp(this.otp);
}
otpOKButton.Width = buttonW;
otpOKButton.Height = buttonH;
otpOKButton.Draw();

// if (ImGui.Button("OK", buttonSize)) // || doEnter)
// {
// TryAcceptOtp(this.otpValue);
// }

ImGui.SameLine();

if (ImGui.Button("Cancel", buttonSize))
{
this.Cancelled = true;
}
otpCancelButton.Width = buttonW;
otpCancelButton.Height = buttonH;
otpCancelButton.Draw();

// if (ImGui.Button("Cancel", buttonSize))
// {
// this.Cancelled = true;
// }
}

ImGui.EndChild();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class SettingsPage : Page
new SettingsTabPatching(),
new SettingsTabWine(),
new SettingsTabDalamud(),
new SettingsTabSteamTool(),
new SettingsTabAutoStart(),
new SettingsTabAbout(),
new SettingsTabDebug(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public class SettingsTabGame : SettingsTab
new SettingsEntry<DpiAwareness>("Game DPI Awareness", "Select the game's DPI Awareness. Change this if the game's scaling looks wrong.", () => Program.Config.DpiAwareness ?? DpiAwareness.Unaware, x => Program.Config.DpiAwareness = x),
new SettingsEntry<bool>("Free Trial Account", "Check this if you are using a free trial account.", () => Program.Config.IsFt ?? false, x => Program.Config.IsFt = x),
new SettingsEntry<bool>("Use XIVLauncher authenticator/OTP macros", "Check this if you want to use the XIVLauncher authenticator app or macros.", () => Program.Config.IsOtpServer ?? false, x => Program.Config.IsOtpServer = x),
new SettingsEntry<bool>("Ignore Steam", "Check this if you do not want XIVLauncher to communicate with Steam (Requires Restart).", () => Program.Config.IsIgnoringSteam ?? false, x => Program.Config.IsIgnoringSteam = x),
new SettingsEntry<bool>("Ignore Steam", "Check this if you do not want XIVLauncher to communicate with Steam (Requires Restart).", () => Program.Config.IsIgnoringSteam ?? false, x => Program.Config.IsIgnoringSteam = x)
{
CheckVisibility = () => !CoreEnvironmentSettings.IsSteamCompatTool,
},
new SettingsEntry<bool>("Use Experimental UID Cache", "Tries to save your login token for the next start. Can result in launching with expired sessions.\nDisable if receiving FFXIV error 1012 or 500X.", () => Program.Config.IsUidCacheEnabled ?? false, x => Program.Config.IsUidCacheEnabled = x),
};

Expand Down
Loading
Loading