apply window-mode

This commit is contained in:
DismissedLight
2022-12-23 16:29:28 +08:00
parent a97bab8a1c
commit 50459923f9
8 changed files with 104 additions and 18 deletions

View File

@@ -43,8 +43,10 @@
<CornerRadius x:Key="CompatCornerRadiusBottom">0,0,6,6</CornerRadius>
<CornerRadius x:Key="CompatCornerRadiusSmall">2</CornerRadius>
<!-- Converters -->
<cwuc:BoolNegationConverter x:Key="BoolNegationConverter"/>
<cwuc:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
<shmmc:AchievementIconConverter x:Key="AchievementIconConverter"/>
<shmmc:AvatarCardConverter x:Key="AvatarCardConverter"/>
<shmmc:AvatarIconConverter x:Key="AvatarIconConverter"/>
<shmmc:AvatarNameCardPicConverter x:Key="AvatarNameCardPicConverter"/>
<shmmc:AvatarSideIconConverter x:Key="AvatarSideIconConverter"/>

View File

@@ -25,6 +25,17 @@ public class CommandLineBuilder
return condition ? Append(name, value) : this;
}
/// <summary>
/// 当参数不为 null 时添加参数
/// </summary>
/// <param name="name">参数名称</param>
/// <param name="value">值</param>
/// <returns>命令行建造器</returns>
public CommandLineBuilder AppendIfNotNull(string name, object? value = null)
{
return AppendIf(name, value != null, value);
}
/// <summary>
/// 添加参数
/// </summary>

View File

@@ -0,0 +1,37 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Control;
namespace Snap.Hutao.Model.Metadata.Converter;
/// <summary>
/// 角色卡片转换器
/// </summary>
internal class AvatarCardConverter : ValueConverterBase<string, Uri>
{
private const string BaseUrl = "https://static.snapgenshin.com/AvatarCard/{0}_Card.png";
private static readonly Uri UIAvatarIconCostumeCard = new("https://static.snapgenshin.com/AvatarCard/UI_AvatarIcon_Costume_Card.png");
/// <summary>
/// 名称转Uri
/// </summary>
/// <param name="name">名称</param>
/// <returns>链接</returns>
public static Uri IconNameToUri(string name)
{
if (string.IsNullOrEmpty(name))
{
return UIAvatarIconCostumeCard;
}
return new Uri(string.Format(BaseUrl, name));
}
/// <inheritdoc/>
public override Uri Convert(string from)
{
return IconNameToUri(from);
}
}

View File

@@ -12,6 +12,8 @@ internal class ItemIconConverter : ValueConverterBase<string, Uri>
{
private const string BaseUrl = "https://static.snapgenshin.com/ItemIcon/{0}.png";
private static readonly Uri UIItemIconNone = new("https://static.snapgenshin.com/Bg/UI_ItemIcon_None.png");
/// <summary>
/// 名称转Uri
/// </summary>

View File

@@ -244,6 +244,7 @@ internal class GameService : IGameService, IDisposable
string commandLine = new CommandLineBuilder()
.AppendIf("-popupwindow", configuration.IsBorderless)
.Append("-screen-fullscreen", configuration.IsFullScreen ? 1 : 0)
.AppendIfNotNull("-window-mode", configuration.WindowMode)
.Append("-screen-width", configuration.ScreenWidth)
.Append("-screen-height", configuration.ScreenHeight)
.ToString();

View File

@@ -57,4 +57,15 @@ internal readonly struct LaunchConfiguration
UnlockFPS = unlockFps;
TargetFPS = targetFps;
}
/// <summary>
/// 窗口模式字符串
/// </summary>
public string? WindowMode
{
get
{
return IsFullScreen ? "exclusive" : IsBorderless ? "borderless" : null;
}
}
}

View File

@@ -150,9 +150,12 @@ internal class GameFpsUnlocker : IGameFpsUnlocker
Must.Range(adr >= 0, "未匹配到FPS字节");
int rip = adr + 2;
int rel = image.Fixed<int>(rip + 2); // Unsafe.ReadUnaligned<int>(ref image[rip + 2]);
int ofs = rip + rel + 6;
fpsAddress = (nuint)((long)unityPlayer.modBaseAddr + ofs);
fixed (byte* pSpan = image)
{
int rip = adr + 2;
int rel = *(int*)(pSpan + rip + 2); // Unsafe.ReadUnaligned<int>(ref image[rip + 2]);
int ofs = rip + rel + 6;
fpsAddress = (nuint)((long)unityPlayer.modBaseAddr + ofs);
}
}
}

View File

@@ -381,7 +381,11 @@
<x:Int32>0</x:Int32>
</cwuc:Case.Value>
<Grid>
<shvc:ItemIcon Quality="QUALITY_ORANGE"/>
<shvc:ItemIcon
Width="80"
Height="80"
Icon="https://static.snapgenshin.com/Bg/UI_ItemIcon_None.png"
Quality="QUALITY_ORANGE"/>
</Grid>
</cwuc:Case>
<cwuc:Case>
@@ -389,11 +393,11 @@
<x:Int32>1</x:Int32>
</cwuc:Case.Value>
<Grid>
<shvc:ItemIcon Quality="QUALITY_ORANGE"/>
<shci:CachedImage
<shvc:ItemIcon
Width="80"
Margin="0,0,0,0"
Source="{Binding Icons[0]}"/>
Height="80"
Icon="{Binding Icons[0]}"
Quality="QUALITY_ORANGE"/>
</Grid>
</cwuc:Case>
<cwuc:Case>
@@ -520,17 +524,32 @@
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Header="衣装">
<ItemsControl ItemsSource="{Binding Selected.Costumes}">
<ItemsControl Margin="0,16,0,0" ItemsSource="{Binding Selected.Costumes}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,-4">
<TextBlock Margin="16,16,16,0" Text="{Binding Name}"/>
<TextBlock
Margin="16,8,16,16"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding Description}"/>
<MenuFlyoutSeparator Margin="16,0"/>
</StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<shci:CachedImage
Width="80"
Height="80"
Margin="16,0,16,16"
Source="https://static.snapgenshin.com/AvatarCard/UI_AvatarIcon_Costume_Card.png"/>
<shci:CachedImage
Width="80"
Height="80"
Margin="16,0,16,16"
Source="{Binding Icon, Converter={StaticResource AvatarCardConverter}}"/>
<StackPanel Grid.Column="1" Margin="0,0,16,-4">
<TextBlock Text="{Binding Name}"/>
<TextBlock
Margin="0,8,0,16"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding Description}"/>
</StackPanel>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>