Skip to content

Commit 3817d80

Browse files
committed
Add MobileLayout support for StarRail
#466 Thanks for the details @ubdjshdb
1 parent 9b84d75 commit 3817d80

File tree

7 files changed

+124
-72
lines changed

7 files changed

+124
-72
lines changed

CollapseLauncher/Classes/GameManagement/GameSettings/StarRail/RegistryClass/Model.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ public enum AntialiasingMode
3535
internal class Model : IGameSettingsValue<Model>
3636
{
3737
#region Fields
38-
private const string _ValueName = "GraphicsSettings_Model_h2986158309";
38+
39+
public const string _ValueName = "GraphicsSettings_Model_h2986158309";
3940
private const string _GraphicsQuality = "GraphicsSettings_GraphicsQuality_h523255858";
41+
4042
public static readonly int[] FPSIndex = new int[] { 30, 60, 120 };
4143
public const int FPSDefaultIndex = 1; // 60 in FPSIndex[]
4244
public static Dictionary<int, int> FPSIndexDict = GenerateStaticFPSIndexDict();

CollapseLauncher/Classes/GameManagement/GameSettings/Universal/RegistryClass/CollapseMiscSetting.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public bool UseCustomArguments
8585
public string GamePostExitCommand { get; set; } = "";
8686

8787
/// <summary>
88-
/// Use mobile layout. Currently only available for Genshin Impact.
88+
/// Use mobile layout. Currently only available for Genshin and StarRail.
8989
/// </summary>
9090
public bool LaunchMobileMode { get; set; } = false;
9191
#endregion

CollapseLauncher/XAMLs/MainApp/Pages/GameSettingsPages/StarRailGameSettingsPage.Ext.cs

+6
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ public bool IsGameBoost
334334
get => Settings.SettingsCollapseMisc.UseGameBoost;
335335
set => Settings.SettingsCollapseMisc.UseGameBoost = value;
336336
}
337+
338+
public bool IsMobileMode
339+
{
340+
get => Settings.SettingsCollapseMisc.LaunchMobileMode;
341+
set => Settings.SettingsCollapseMisc.LaunchMobileMode = value;
342+
}
337343
#endregion
338344

339345
#region Advanced Settings

CollapseLauncher/XAMLs/MainApp/Pages/GameSettingsPages/StarRailGameSettingsPage.xaml

+85-68
Original file line numberDiff line numberDiff line change
@@ -40,81 +40,98 @@
4040
Style="{ThemeResource SubtitleTextBlockStyle}"
4141
Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_ResolutionPanel}"
4242
TextWrapping="Wrap" />
43-
<StackPanel x:Name="GameResolutionWindow"
44-
Margin="0,0,0,8"
45-
Orientation="Vertical">
46-
<Grid>
47-
<Border x:Name="VSyncTooltip"
48-
Background="Transparent"
49-
ToolTipService.ToolTip="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_VSync_Help}" />
50-
<CheckBox x:Name="VSyncToggle"
43+
<Grid>
44+
<Grid.ColumnDefinitions>
45+
<ColumnDefinition />
46+
<ColumnDefinition />
47+
</Grid.ColumnDefinitions>
48+
<StackPanel x:Name="GameResolutionWindow"
49+
Grid.Column="0"
50+
Margin="0,0,0,8"
51+
Orientation="Vertical">
52+
<Grid>
53+
<Border x:Name="VSyncTooltip"
54+
Background="Transparent"
55+
ToolTipService.ToolTip="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_VSync_Help}" />
56+
<CheckBox x:Name="VSyncToggle"
57+
HorizontalAlignment="Left"
58+
VerticalAlignment="Center"
59+
IsChecked="{x:Bind EnableVSync, Mode=TwoWay}">
60+
<TextBlock Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_VSync}"
61+
TextWrapping="Wrap" />
62+
</CheckBox>
63+
</Grid>
64+
<CheckBox x:Name="GameResolutionFullscreen"
5165
HorizontalAlignment="Left"
5266
VerticalAlignment="Center"
53-
IsChecked="{x:Bind EnableVSync, Mode=TwoWay}">
54-
<TextBlock Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_VSync}"
67+
IsChecked="{x:Bind IsFullscreenEnabled, Mode=TwoWay}">
68+
<TextBlock Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_Fullscreen}"
5569
TextWrapping="Wrap" />
5670
</CheckBox>
57-
</Grid>
58-
<CheckBox x:Name="GameResolutionFullscreen"
59-
HorizontalAlignment="Left"
60-
VerticalAlignment="Center"
61-
IsChecked="{x:Bind IsFullscreenEnabled, Mode=TwoWay}">
62-
<TextBlock Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_Fullscreen}"
63-
TextWrapping="Wrap" />
64-
</CheckBox>
65-
<CheckBox x:Name="GameResolutionBorderless"
66-
HorizontalAlignment="Left"
67-
VerticalAlignment="Center"
68-
IsChecked="{x:Bind IsBorderlessEnabled, Mode=TwoWay}">
69-
<TextBlock Text="{x:Bind helper:Locale.Lang._GameSettingsPage.Graphics_Borderless}"
70-
TextWrapping="Wrap" />
71-
</CheckBox>
72-
<Grid>
73-
<Grid.ColumnDefinitions>
74-
<ColumnDefinition />
75-
<ColumnDefinition Width="Auto" />
76-
</Grid.ColumnDefinitions>
77-
<CheckBox x:Name="GameWindowResizable"
78-
HorizontalAlignment="Stretch"
71+
<CheckBox x:Name="GameResolutionBorderless"
72+
HorizontalAlignment="Left"
7973
VerticalAlignment="Center"
80-
IsChecked="{x:Bind IsResizableWindow, Mode=TwoWay}"
81-
IsEnabled="{x:Bind IsCanResizableWindow, Mode=OneWay}">
82-
<TextBlock Text="{x:Bind helper:Locale.Lang._GameSettingsPage.Graphics_ResizableWindow}"
74+
IsChecked="{x:Bind IsBorderlessEnabled, Mode=TwoWay}">
75+
<TextBlock Text="{x:Bind helper:Locale.Lang._GameSettingsPage.Graphics_Borderless}"
8376
TextWrapping="Wrap" />
8477
</CheckBox>
85-
<Button Grid.Column="1"
86-
Margin="8,-4,0,0"
87-
Style="{ThemeResource ButtonRevealStyle}">
88-
<Button.Content>
89-
<FontIcon FontFamily="{ThemeResource FontAwesome}"
90-
FontSize="12"
91-
Glyph="&#x3f;" />
92-
</Button.Content>
93-
<Button.Flyout>
94-
<Flyout AllowFocusOnInteraction="True">
95-
<TextBlock MaxWidth="360"
96-
FontWeight="SemiBold"
97-
Text="{x:Bind helper:Locale.Lang._GameSettingsPage.Graphics_ResizableWindowTooltip}"
98-
TextAlignment="Center"
99-
TextWrapping="Wrap" />
100-
</Flyout>
101-
</Button.Flyout>
102-
</Button>
103-
</Grid>
104-
<!--
105-
Exclusive Fullscreen option is disabled in Honkai:Star Rail due to it being ignored by the game
106-
Delete `Visibility="Collapsed"' to revert this change
107-
-->
108-
<CheckBox x:Name="GameResolutionFullscreenExclusive"
109-
HorizontalAlignment="Left"
110-
VerticalAlignment="Center"
111-
IsChecked="{x:Bind IsExclusiveFullscreenEnabled, Mode=TwoWay}"
112-
IsEnabled="{x:Bind IsCanExclusiveFullscreen, Mode=OneWay}"
113-
Visibility="Collapsed">
114-
<TextBlock Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_ExclusiveFullscreen}"
115-
TextWrapping="Wrap" />
116-
</CheckBox>
117-
</StackPanel>
78+
<Grid>
79+
<Grid.ColumnDefinitions>
80+
<ColumnDefinition />
81+
<ColumnDefinition Width="Auto" />
82+
</Grid.ColumnDefinitions>
83+
<CheckBox x:Name="GameWindowResizable"
84+
HorizontalAlignment="Stretch"
85+
VerticalAlignment="Center"
86+
IsChecked="{x:Bind IsResizableWindow, Mode=TwoWay}"
87+
IsEnabled="{x:Bind IsCanResizableWindow, Mode=OneWay}">
88+
<TextBlock Text="{x:Bind helper:Locale.Lang._GameSettingsPage.Graphics_ResizableWindow}"
89+
TextWrapping="Wrap" />
90+
</CheckBox>
91+
<Button Grid.Column="1"
92+
Margin="8,-4,0,0"
93+
Style="{ThemeResource ButtonRevealStyle}">
94+
<Button.Content>
95+
<FontIcon FontFamily="{ThemeResource FontAwesome}"
96+
FontSize="12"
97+
Glyph="&#x3f;" />
98+
</Button.Content>
99+
<Button.Flyout>
100+
<Flyout AllowFocusOnInteraction="True">
101+
<TextBlock MaxWidth="360"
102+
FontWeight="SemiBold"
103+
Text="{x:Bind helper:Locale.Lang._GameSettingsPage.Graphics_ResizableWindowTooltip}"
104+
TextAlignment="Center"
105+
TextWrapping="Wrap" />
106+
</Flyout>
107+
</Button.Flyout>
108+
</Button>
109+
</Grid>
110+
<!--
111+
Exclusive Fullscreen option is disabled in Honkai:Star Rail due to it being ignored by the game
112+
Delete `Visibility="Collapsed"' to revert this change
113+
-->
114+
<CheckBox x:Name="GameResolutionFullscreenExclusive"
115+
HorizontalAlignment="Left"
116+
VerticalAlignment="Center"
117+
IsChecked="{x:Bind IsExclusiveFullscreenEnabled, Mode=TwoWay}"
118+
IsEnabled="{x:Bind IsCanExclusiveFullscreen, Mode=OneWay}"
119+
Visibility="Collapsed">
120+
<TextBlock Text="{x:Bind helper:Locale.Lang._StarRailGameSettingsPage.Graphics_ExclusiveFullscreen}"
121+
TextWrapping="Wrap" />
122+
</CheckBox>
123+
</StackPanel>
124+
<StackPanel Grid.Column="1"
125+
Margin="4,0,0,0">
126+
<CheckBox x:Name="MobileModeToggle"
127+
HorizontalAlignment="Left"
128+
VerticalAlignment="Center"
129+
IsChecked="{x:Bind IsMobileMode, Mode=TwoWay}">
130+
<TextBlock Text="{x:Bind helper:Locale.Lang._GameSettingsPage.MobileLayout}"
131+
TextWrapping="Wrap" />
132+
</CheckBox>
133+
</StackPanel>
134+
</Grid>
118135
<Grid Margin="0,0,0,16">
119136
<Grid.ColumnDefinitions>
120137
<ColumnDefinition Width="Auto" />

CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs

+27
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,33 @@ internal string GetLaunchArguments(IGameSettingsUniversal _Settings)
14881488
parameter.Append("-window-mode exclusive -screen-fullscreen 1 ");
14891489
RequireWindowExclusivePayload = true;
14901490
}
1491+
1492+
// Enable mobile mode
1493+
if (_Settings.SettingsCollapseMisc.LaunchMobileMode)
1494+
{
1495+
const string regLoc = GameSettings.StarRail.Model._ValueName;
1496+
var regRoot = GameSettings.Base.SettingsBase.RegistryRoot;
1497+
1498+
if (regRoot != null || !string.IsNullOrEmpty(regLoc))
1499+
{
1500+
var regModel = (byte[])regRoot!.GetValue(regLoc, null);
1501+
1502+
if (regModel != null)
1503+
{
1504+
string regB64 = Convert.ToBase64String(regModel);
1505+
parameter.Append($"-is_cloud 1 -platform_type CLOUD_WEB_TOUCH -graphics_setting {regB64} ");
1506+
}
1507+
else
1508+
{
1509+
LogWriteLine("Failed enabling MobileMode for HSR: regModel is null.", LogType.Error, true);
1510+
}
1511+
}
1512+
else
1513+
{
1514+
LogWriteLine("Failed enabling MobileMode for HSR: regRoot/regLoc is unexpectedly uninitialized.",
1515+
LogType.Error, true);
1516+
}
1517+
}
14911518

14921519
Size screenSize = _Settings.SettingsScreen.sizeRes;
14931520

Hi3Helper.EncTool

Hi3Helper.Http

0 commit comments

Comments
 (0)