Skip to content

Commit

Permalink
[StarRail GSP] Stop graphics settings saving if A/B test flag is found
Browse files Browse the repository at this point in the history
  • Loading branch information
bagusnl committed Aug 25, 2024
1 parent 18693e4 commit d08e264
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using CollapseLauncher.GameSettings.StarRail.Context;
using CollapseLauncher.Interfaces;
using CollapseLauncher.Pages;
using Hi3Helper;
using Hi3Helper.EncTool;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

Check warning on line 10 in CollapseLauncher/Classes/GameManagement/GameSettings/StarRail/RegistryClass/Model.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant using directive

Using directive is not required by the code and can be safely removed

Check warning

Code scanning / QDNET

Redundant using directive Warning

Using directive is not required by the code and can be safely removed
using static CollapseLauncher.GameSettings.Base.SettingsBase;
using static Hi3Helper.Logger;

Expand Down Expand Up @@ -329,6 +331,13 @@ public void Save()
try
{
if (RegistryRoot == null) throw new NullReferenceException($"Cannot save {_ValueName} since RegistryKey is unexpectedly not initialized!");

if (StarRailGameSettingsPage.CheckAbTest())
{
LogWriteLine("[StarRailGameSettings::Model] Graphics settings could not be saved due to A/B test flag is found!",
LogType.Error, true);
return;
}

RegistryRoot.SetValue(_GraphicsQuality, Quality.Custom, RegistryValueKind.DWord);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Numerics;
using System.Threading.Tasks;

Check warning on line 20 in CollapseLauncher/XAMLs/MainApp/Pages/GameSettingsPages/StarRailGameSettingsPage.xaml.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant using directive

Using directive is not required by the code and can be safely removed

Check warning

Code scanning / QDNET

Redundant using directive Warning

Using directive is not required by the code and can be safely removed
using Windows.UI;
using static Hi3Helper.Locale;
using static Hi3Helper.Logger;
Expand Down Expand Up @@ -88,12 +89,24 @@ private async void LoadPage()
InheritApplyTextColor = ApplyText.Foreground!;
#nullable enable
// A/B Testing as of 2023-12-26 (HSR v1.6.0)
if (CheckAbTest())
{
await SimpleDialogs.Dialog_GenericWarning(Content!);
}
}

/// <summary>
/// Returns true if A/B test registry identifier is found.
/// </summary>
public static bool CheckAbTest()
{
object? abValue = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Cognosphere\Star Rail", _AbValueName, null);
if (abValue != null)
{
await SimpleDialogs.Dialog_GenericWarning(Content!);
LogWriteLine($"A/B Value Found. Settings will not apply to the game.", LogType.Warning, true);
return true;
}
return false;
}
#nullable disable
private void RegistryExportClick(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit d08e264

Please sign in to comment.