Skip to content

Commit

Permalink
Add MobileLayout support for StarRail
Browse files Browse the repository at this point in the history
#466
Thanks for the details @ubdjshdb
  • Loading branch information
bagusnl committed May 20, 2024
1 parent 9b84d75 commit 3817d80
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ public enum AntialiasingMode
internal class Model : IGameSettingsValue<Model>
{
#region Fields
private const string _ValueName = "GraphicsSettings_Model_h2986158309";

public const string _ValueName = "GraphicsSettings_Model_h2986158309";
private const string _GraphicsQuality = "GraphicsSettings_GraphicsQuality_h523255858";

public static readonly int[] FPSIndex = new int[] { 30, 60, 120 };
public const int FPSDefaultIndex = 1; // 60 in FPSIndex[]
public static Dictionary<int, int> FPSIndexDict = GenerateStaticFPSIndexDict();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public bool UseCustomArguments
public string GamePostExitCommand { get; set; } = "";

/// <summary>
/// Use mobile layout. Currently only available for Genshin Impact.
/// Use mobile layout. Currently only available for Genshin and StarRail.
/// </summary>
public bool LaunchMobileMode { get; set; } = false;
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ public bool IsGameBoost
get => Settings.SettingsCollapseMisc.UseGameBoost;
set => Settings.SettingsCollapseMisc.UseGameBoost = value;
}

public bool IsMobileMode
{
get => Settings.SettingsCollapseMisc.LaunchMobileMode;
set => Settings.SettingsCollapseMisc.LaunchMobileMode = value;
}
#endregion

#region Advanced Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,81 +40,98 @@
Style="{ThemeResource SubtitleTextBlockStyle}"
Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_ResolutionPanel}"
TextWrapping="Wrap" />
<StackPanel x:Name="GameResolutionWindow"
Margin="0,0,0,8"
Orientation="Vertical">
<Grid>
<Border x:Name="VSyncTooltip"
Background="Transparent"
ToolTipService.ToolTip="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_VSync_Help}" />
<CheckBox x:Name="VSyncToggle"
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel x:Name="GameResolutionWindow"
Grid.Column="0"
Margin="0,0,0,8"
Orientation="Vertical">
<Grid>
<Border x:Name="VSyncTooltip"
Background="Transparent"
ToolTipService.ToolTip="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_VSync_Help}" />
<CheckBox x:Name="VSyncToggle"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsChecked="{x:Bind EnableVSync, Mode=TwoWay}">
<TextBlock Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_VSync}"
TextWrapping="Wrap" />
</CheckBox>
</Grid>
<CheckBox x:Name="GameResolutionFullscreen"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsChecked="{x:Bind EnableVSync, Mode=TwoWay}">
<TextBlock Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_VSync}"
IsChecked="{x:Bind IsFullscreenEnabled, Mode=TwoWay}">
<TextBlock Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_Fullscreen}"
TextWrapping="Wrap" />
</CheckBox>
</Grid>
<CheckBox x:Name="GameResolutionFullscreen"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsChecked="{x:Bind IsFullscreenEnabled, Mode=TwoWay}">
<TextBlock Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_Fullscreen}"
TextWrapping="Wrap" />
</CheckBox>
<CheckBox x:Name="GameResolutionBorderless"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsChecked="{x:Bind IsBorderlessEnabled, Mode=TwoWay}">
<TextBlock Text="{x:Bind helper:Locale.Lang._GameSettingsPage.Graphics_Borderless}"
TextWrapping="Wrap" />
</CheckBox>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<CheckBox x:Name="GameWindowResizable"
HorizontalAlignment="Stretch"
<CheckBox x:Name="GameResolutionBorderless"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsChecked="{x:Bind IsResizableWindow, Mode=TwoWay}"
IsEnabled="{x:Bind IsCanResizableWindow, Mode=OneWay}">
<TextBlock Text="{x:Bind helper:Locale.Lang._GameSettingsPage.Graphics_ResizableWindow}"
IsChecked="{x:Bind IsBorderlessEnabled, Mode=TwoWay}">
<TextBlock Text="{x:Bind helper:Locale.Lang._GameSettingsPage.Graphics_Borderless}"
TextWrapping="Wrap" />
</CheckBox>
<Button Grid.Column="1"
Margin="8,-4,0,0"
Style="{ThemeResource ButtonRevealStyle}">
<Button.Content>
<FontIcon FontFamily="{ThemeResource FontAwesome}"
FontSize="12"
Glyph="&#x3f;" />
</Button.Content>
<Button.Flyout>
<Flyout AllowFocusOnInteraction="True">
<TextBlock MaxWidth="360"
FontWeight="SemiBold"
Text="{x:Bind helper:Locale.Lang._GameSettingsPage.Graphics_ResizableWindowTooltip}"
TextAlignment="Center"
TextWrapping="Wrap" />
</Flyout>
</Button.Flyout>
</Button>
</Grid>
<!--
Exclusive Fullscreen option is disabled in Honkai:Star Rail due to it being ignored by the game
Delete `Visibility="Collapsed"' to revert this change
-->
<CheckBox x:Name="GameResolutionFullscreenExclusive"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsChecked="{x:Bind IsExclusiveFullscreenEnabled, Mode=TwoWay}"
IsEnabled="{x:Bind IsCanExclusiveFullscreen, Mode=OneWay}"
Visibility="Collapsed">
<TextBlock Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_ExclusiveFullscreen}"
TextWrapping="Wrap" />
</CheckBox>
</StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<CheckBox x:Name="GameWindowResizable"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsChecked="{x:Bind IsResizableWindow, Mode=TwoWay}"
IsEnabled="{x:Bind IsCanResizableWindow, Mode=OneWay}">
<TextBlock Text="{x:Bind helper:Locale.Lang._GameSettingsPage.Graphics_ResizableWindow}"
TextWrapping="Wrap" />
</CheckBox>
<Button Grid.Column="1"
Margin="8,-4,0,0"
Style="{ThemeResource ButtonRevealStyle}">
<Button.Content>
<FontIcon FontFamily="{ThemeResource FontAwesome}"
FontSize="12"
Glyph="&#x3f;" />
</Button.Content>
<Button.Flyout>
<Flyout AllowFocusOnInteraction="True">
<TextBlock MaxWidth="360"
FontWeight="SemiBold"
Text="{x:Bind helper:Locale.Lang._GameSettingsPage.Graphics_ResizableWindowTooltip}"
TextAlignment="Center"
TextWrapping="Wrap" />
</Flyout>
</Button.Flyout>
</Button>
</Grid>
<!--
Exclusive Fullscreen option is disabled in Honkai:Star Rail due to it being ignored by the game
Delete `Visibility="Collapsed"' to revert this change
-->
<CheckBox x:Name="GameResolutionFullscreenExclusive"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsChecked="{x:Bind IsExclusiveFullscreenEnabled, Mode=TwoWay}"
IsEnabled="{x:Bind IsCanExclusiveFullscreen, Mode=OneWay}"
Visibility="Collapsed">
<TextBlock Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_ExclusiveFullscreen}"
TextWrapping="Wrap" />
</CheckBox>
</StackPanel>
<StackPanel Grid.Column="1"
Margin="4,0,0,0">
<CheckBox x:Name="MobileModeToggle"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsChecked="{x:Bind IsMobileMode, Mode=TwoWay}">
<TextBlock Text="{x:Bind helper:Locale.Lang._GameSettingsPage.MobileLayout}"
TextWrapping="Wrap" />
</CheckBox>
</StackPanel>
</Grid>
<Grid Margin="0,0,0,16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down
27 changes: 27 additions & 0 deletions CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,33 @@ internal string GetLaunchArguments(IGameSettingsUniversal _Settings)
parameter.Append("-window-mode exclusive -screen-fullscreen 1 ");
RequireWindowExclusivePayload = true;
}

// Enable mobile mode
if (_Settings.SettingsCollapseMisc.LaunchMobileMode)
{
const string regLoc = GameSettings.StarRail.Model._ValueName;
var regRoot = GameSettings.Base.SettingsBase.RegistryRoot;

if (regRoot != null || !string.IsNullOrEmpty(regLoc))
{
var regModel = (byte[])regRoot!.GetValue(regLoc, null);

if (regModel != null)
{
string regB64 = Convert.ToBase64String(regModel);
parameter.Append($"-is_cloud 1 -platform_type CLOUD_WEB_TOUCH -graphics_setting {regB64} ");
}
else
{
LogWriteLine("Failed enabling MobileMode for HSR: regModel is null.", LogType.Error, true);
}
}
else
{
LogWriteLine("Failed enabling MobileMode for HSR: regRoot/regLoc is unexpectedly uninitialized.",
LogType.Error, true);
}
}

Size screenSize = _Settings.SettingsScreen.sizeRes;

Expand Down
2 changes: 1 addition & 1 deletion Hi3Helper.EncTool
2 changes: 1 addition & 1 deletion Hi3Helper.Http

0 comments on commit 3817d80

Please sign in to comment.