mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix process name detection
This commit is contained in:
@@ -10,6 +10,7 @@ using Snap.Hutao.Service.Abstraction;
|
||||
using Snap.Hutao.Service.DailyNote;
|
||||
using Snap.Hutao.Service.Metadata;
|
||||
using Snap.Hutao.Service.Navigation;
|
||||
using System.Diagnostics;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace Snap.Hutao.Core.LifeCycle;
|
||||
@@ -220,7 +221,7 @@ internal static class Activation
|
||||
if (!isRedirected)
|
||||
{
|
||||
// It's a direct open process, should exit immediately.
|
||||
Environment.Exit(0);
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -13,10 +13,15 @@ internal static class StaticResource
|
||||
/// </summary>
|
||||
public static void FulfillAllContracts()
|
||||
{
|
||||
LocalSetting.Set(SettingKeys.StaticResourceV1Contract, true);
|
||||
LocalSetting.Set(SettingKeys.StaticResourceV2Contract, true);
|
||||
LocalSetting.Set(SettingKeys.StaticResourceV3Contract, true);
|
||||
LocalSetting.Set(SettingKeys.StaticResourceV4Contract, true);
|
||||
SetContractsState(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 完成所有合约
|
||||
/// </summary>
|
||||
public static void UnfulfillAllContracts()
|
||||
{
|
||||
SetContractsState(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -40,4 +45,12 @@ internal static class StaticResource
|
||||
|| (!LocalSetting.Get(SettingKeys.StaticResourceV3Contract, false))
|
||||
|| (!LocalSetting.Get(SettingKeys.StaticResourceV4Contract, false));
|
||||
}
|
||||
|
||||
private static void SetContractsState(bool state)
|
||||
{
|
||||
LocalSetting.Set(SettingKeys.StaticResourceV1Contract, state);
|
||||
LocalSetting.Set(SettingKeys.StaticResourceV2Contract, state);
|
||||
LocalSetting.Set(SettingKeys.StaticResourceV3Contract, state);
|
||||
LocalSetting.Set(SettingKeys.StaticResourceV4Contract, state);
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class Avatar : ICalculableSource<ICalculableAvatar>
|
||||
/// <summary>
|
||||
/// 等级
|
||||
/// </summary>
|
||||
public string Level { get; set; } = default!;
|
||||
public string Level { get => $"Lv.{LevelNumber}"; }
|
||||
|
||||
/// <summary>
|
||||
/// 武器
|
||||
@@ -63,6 +63,11 @@ public class Avatar : ICalculableSource<ICalculableAvatar>
|
||||
/// </summary>
|
||||
public List<Constellation> Constellations { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 激活的命之座个数
|
||||
/// </summary>
|
||||
public int ActivatedConstellationCount { get => Constellations.Where(c => c.IsActivated).Count(); }
|
||||
|
||||
/// <summary>
|
||||
/// 技能列表
|
||||
/// </summary>
|
||||
|
||||
@@ -17,16 +17,21 @@ public class Skill : NameIconDescription, ICalculableSource<ICalculableSkill>
|
||||
/// </summary>
|
||||
public LevelParam<string, ParameterInfo> Info { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 不计算命座的技能等级
|
||||
/// </summary>
|
||||
public int LevelNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 不计算命座的技能等级字符串
|
||||
/// </summary>
|
||||
public string Level { get => $"Lv.{LevelNumber}"; }
|
||||
|
||||
/// <summary>
|
||||
/// 技能组Id
|
||||
/// </summary>
|
||||
internal int GroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 技能等级,仅用于养成计算
|
||||
/// </summary>
|
||||
internal int LevelNumber { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ICalculableSkill ToCalculable()
|
||||
{
|
||||
|
||||
@@ -17,10 +17,15 @@ public class Weapon : EquipBase, ICalculableSource<ICalculableWeapon>
|
||||
/// </summary>
|
||||
public Pair<string, string> SubProperty { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 精炼等级
|
||||
/// </summary>
|
||||
public int AffixLevelNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 精炼属性
|
||||
/// </summary>
|
||||
public string AffixLevel { get; set; } = default!;
|
||||
public string AffixLevel { get => string.Format(SH.ModelBindingAvatarPropertyWeaponAffixFormat, AffixLevelNumber); }
|
||||
|
||||
/// <summary>
|
||||
/// 精炼名称
|
||||
|
||||
@@ -34,8 +34,6 @@ public static partial class Program
|
||||
Application.Start(InitializeApp);
|
||||
Control.ScopedPage.DisposePreviousScope();
|
||||
}
|
||||
|
||||
AppInstance.GetCurrent().UnregisterKey();
|
||||
}
|
||||
|
||||
private static void InitializeApp(ApplicationInitializationCallbackParams param)
|
||||
|
||||
@@ -276,6 +276,15 @@ namespace Snap.Hutao.Resource.Localization {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 精炼 {0} 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string ModelBindingAvatarPropertyWeaponAffixFormat {
|
||||
get {
|
||||
return ResourceManager.GetString("ModelBindingAvatarPropertyWeaponAffixFormat", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 周一/周四/周日 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -2130,6 +2139,24 @@ namespace Snap.Hutao.Resource.Localization {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 详细数据 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string ViewPageAvatarPropertyPivotDetailHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("ViewPageAvatarPropertyPivotDetailHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 总览数据 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string ViewPageAvatarPropertyPivotOverviewHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("ViewPageAvatarPropertyPivotOverviewHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 初始词条 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -3444,6 +3471,42 @@ namespace Snap.Hutao.Resource.Localization {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 重置 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string ViewPageSettingResetAction {
|
||||
get {
|
||||
return ResourceManager.GetString("ViewPageSettingResetAction", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 下次启动时会重新下载所有图像资源 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string ViewPageSettingResetStaticResourceDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("ViewPageSettingResetStaticResourceDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 重置图片资源 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string ViewPageSettingResetStaticResourceHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("ViewPageSettingResetStaticResourceHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 重置成功 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string ViewPageSettingResetSuccessMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("ViewPageSettingResetSuccessMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 更改目录后需要手动移动目录内的数据,否则会重新创建用户数据 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -189,6 +189,9 @@
|
||||
<data name="LaunchGameTitle" xml:space="preserve">
|
||||
<value>选择账号并启动</value>
|
||||
</data>
|
||||
<data name="ModelBindingAvatarPropertyWeaponAffixFormat" xml:space="preserve">
|
||||
<value>精炼 {0}</value>
|
||||
</data>
|
||||
<data name="ModelBindingCultivationDaysOfWeek14" xml:space="preserve">
|
||||
<value>周一/周四/周日</value>
|
||||
</data>
|
||||
@@ -807,6 +810,12 @@
|
||||
<data name="ViewPageAvatarPropertyHeader" xml:space="preserve">
|
||||
<value>角色属性</value>
|
||||
</data>
|
||||
<data name="ViewPageAvatarPropertyPivotDetailHeader" xml:space="preserve">
|
||||
<value>详细数据</value>
|
||||
</data>
|
||||
<data name="ViewPageAvatarPropertyPivotOverviewHeader" xml:space="preserve">
|
||||
<value>总览数据</value>
|
||||
</data>
|
||||
<data name="ViewPageAvatarPropertyPrimaryProperties" xml:space="preserve">
|
||||
<value>初始词条</value>
|
||||
</data>
|
||||
@@ -1245,6 +1254,18 @@
|
||||
<data name="ViewPageSettingGameHeader" xml:space="preserve">
|
||||
<value>游戏</value>
|
||||
</data>
|
||||
<data name="ViewPageSettingResetAction" xml:space="preserve">
|
||||
<value>重置</value>
|
||||
</data>
|
||||
<data name="ViewPageSettingResetStaticResourceDescription" xml:space="preserve">
|
||||
<value>下次启动时会重新下载所有图像资源</value>
|
||||
</data>
|
||||
<data name="ViewPageSettingResetStaticResourceHeader" xml:space="preserve">
|
||||
<value>重置图片资源</value>
|
||||
</data>
|
||||
<data name="ViewPageSettingResetSuccessMessage" xml:space="preserve">
|
||||
<value>重置成功</value>
|
||||
</data>
|
||||
<data name="ViewPageSettingSetDataFolderDescription" xml:space="preserve">
|
||||
<value>更改目录后需要手动移动目录内的数据,否则会重新创建用户数据</value>
|
||||
</data>
|
||||
|
||||
@@ -69,8 +69,6 @@ internal class SummaryAvatarFactory
|
||||
};
|
||||
|
||||
TryApplyCostumeIconToAvatar(ref propertyAvatar, avatar);
|
||||
|
||||
propertyAvatar.Level = $"Lv.{propertyAvatar.LevelNumber}";
|
||||
return propertyAvatar;
|
||||
}
|
||||
|
||||
@@ -153,7 +151,7 @@ internal class SummaryAvatarFactory
|
||||
Id = weapon.Id,
|
||||
LevelNumber = equip.Weapon!.Level,
|
||||
SubProperty = subProperty,
|
||||
AffixLevel = $"精炼{affixLevel + 1}",
|
||||
AffixLevelNumber = affixLevel + 1,
|
||||
AffixName = weapon.Affix?.Name ?? string.Empty,
|
||||
AffixDescription = weapon.Affix?.Descriptions.Single(a => a.Level == affixLevel).Description ?? string.Empty,
|
||||
};
|
||||
|
||||
@@ -38,6 +38,8 @@ internal class SummaryFactoryImplementation
|
||||
Avatars = avatarInfos
|
||||
.Where(a => !AvatarIds.IsPlayer(a.AvatarId))
|
||||
.Select(a => new SummaryAvatarFactory(metadataContext, a).CreateAvatar())
|
||||
.OrderByDescending(a => (int)a.Quality)
|
||||
.ThenByDescending(a => a.ActivatedConstellationCount)
|
||||
.ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,4 +32,14 @@ internal static class GameConstants
|
||||
/// 国际服数据文件夹
|
||||
/// </summary>
|
||||
public const string GenshinImpactData = "GenshinImpact_Data";
|
||||
|
||||
/// <summary>
|
||||
/// 国服进程名
|
||||
/// </summary>
|
||||
public const string YuanShenProcessName = "YuanShen";
|
||||
|
||||
/// <summary>
|
||||
/// 外服进程名
|
||||
/// </summary>
|
||||
public const string GenshinImpactProcessName = "GenshinImpact";
|
||||
}
|
||||
@@ -285,8 +285,8 @@ internal class GameService : IGameService
|
||||
return true;
|
||||
}
|
||||
|
||||
return Process.GetProcessesByName(YuanShenFileName).Any()
|
||||
|| Process.GetProcessesByName(GenshinImpactFileName).Any();
|
||||
return Process.GetProcessesByName(YuanShenProcessName).Any()
|
||||
|| Process.GetProcessesByName(GenshinImpactProcessName).Any();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -156,6 +156,14 @@
|
||||
<Button Command="{Binding Experimental.OpenCacheFolderCommand}" Content="{shcm:ResourceString Name=ViewPageSettingStorageOpenAction}"/>
|
||||
</wsc:Setting.ActionContent>
|
||||
</wsc:Setting>
|
||||
<wsc:Setting
|
||||
Description="{shcm:ResourceString Name=ViewPageSettingResetStaticResourceDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageSettingResetStaticResourceHeader}"
|
||||
Icon="">
|
||||
<wsc:Setting.ActionContent>
|
||||
<Button Command="{Binding ResetStaticResourceCommand}" Content="{shcm:ResourceString Name=ViewPageSettingResetAction}"/>
|
||||
</wsc:Setting.ActionContent>
|
||||
</wsc:Setting>
|
||||
</wsc:SettingsGroup>
|
||||
|
||||
<wsc:SettingsGroup Header="测试功能">
|
||||
@@ -181,16 +189,6 @@
|
||||
Message="{shcm:ResourceString Name=ViewPageSettingDangerousHint}"
|
||||
Severity="Error"/>
|
||||
|
||||
<wsc:Setting
|
||||
Background="{ThemeResource SystemFillColorCriticalBackgroundBrush}"
|
||||
Description="{shcm:ResourceString Name=ViewPageSettingDeleteTaskDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageSettingDeleteTaskHeader}"
|
||||
Icon="">
|
||||
<wsc:Setting.ActionContent>
|
||||
<Button Command="{Binding Experimental.DeleteAllScheduleTasksCommand}" Content="{shcm:ResourceString Name=ViewPageSettingDangerousAction}"/>
|
||||
</wsc:Setting.ActionContent>
|
||||
</wsc:Setting>
|
||||
|
||||
<wsc:Setting
|
||||
Background="{StaticResource SystemFillColorCriticalBackgroundBrush}"
|
||||
Description="{shcm:ResourceString Name=ViewPageSettingDeleteUserDescription}"
|
||||
|
||||
@@ -31,7 +31,6 @@ internal class ExperimentalFeaturesViewModel : ObservableObject
|
||||
OpenCacheFolderCommand = new AsyncRelayCommand(OpenCacheFolderAsync);
|
||||
OpenDataFolderCommand = new AsyncRelayCommand(OpenDataFolderAsync);
|
||||
DeleteUsersCommand = new AsyncRelayCommand(DangerousDeleteUsersAsync);
|
||||
DeleteAllScheduleTasksCommand = new RelayCommand(DangerousDeleteAllScheduleTasks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -49,11 +48,6 @@ internal class ExperimentalFeaturesViewModel : ObservableObject
|
||||
/// </summary>
|
||||
public ICommand DeleteUsersCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 删除所有计划任务命令
|
||||
/// </summary>
|
||||
public ICommand DeleteAllScheduleTasksCommand { get; }
|
||||
|
||||
private Task OpenCacheFolderAsync()
|
||||
{
|
||||
return Launcher.LaunchFolderAsync(ApplicationData.Current.LocalCacheFolder).AsTask();
|
||||
@@ -75,17 +69,4 @@ internal class ExperimentalFeaturesViewModel : ObservableObject
|
||||
infoBarService.Success(SH.ViewModelExperimentalDeleteUserSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
private void DangerousDeleteAllScheduleTasks()
|
||||
{
|
||||
IInfoBarService infoBarService = serviceProvider.GetRequiredService<IInfoBarService>();
|
||||
if (Core.ScheduleTaskHelper.UnregisterAllTasks())
|
||||
{
|
||||
infoBarService.Success(SH.ViewModelExperimentalDeleteTaskSuccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
infoBarService.Warning(SH.ViewModelExperimentalDeleteTaskWarning);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,7 @@ internal class SettingViewModel : Abstraction.ViewModel
|
||||
DeleteGameWebCacheCommand = new RelayCommand(DeleteGameWebCache);
|
||||
ShowSignInWebViewDialogCommand = new AsyncRelayCommand(ShowSignInWebViewDialogAsync);
|
||||
SetDataFolderCommand = new AsyncRelayCommand(SetDataFolderAsync);
|
||||
ResetStaticResourceCommand = new RelayCommand(ResetStaticResource);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -182,6 +183,11 @@ internal class SettingViewModel : Abstraction.ViewModel
|
||||
/// </summary>
|
||||
public ICommand SetDataFolderCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 重置静态资源
|
||||
/// </summary>
|
||||
public ICommand ResetStaticResourceCommand { get; }
|
||||
|
||||
private async Task SetGamePathAsync()
|
||||
{
|
||||
IGameLocator locator = serviceProvider.GetRequiredService<IEnumerable<IGameLocator>>()
|
||||
@@ -260,4 +266,10 @@ internal class SettingViewModel : Abstraction.ViewModel
|
||||
infoBarService.Success(SH.ViewModelSettingSetDataFolderSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetStaticResource()
|
||||
{
|
||||
StaticResource.UnfulfillAllContracts();
|
||||
serviceProvider.GetRequiredService<IInfoBarService>().Success(SH.ViewPageSettingResetSuccessMessage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user