diff --git a/src/Starward.Language/Lang.Designer.cs b/src/Starward.Language/Lang.Designer.cs
index dd25773c2..1aa14762f 100644
--- a/src/Starward.Language/Lang.Designer.cs
+++ b/src/Starward.Language/Lang.Designer.cs
@@ -6377,6 +6377,15 @@ public static string SettingPage_RegistryBasedGameAccountSwitchingFeature {
return ResourceManager.GetString("SettingPage_RegistryBasedGameAccountSwitchingFeature", resourceCulture);
}
}
+
+ ///
+ /// 查找类似 Automatically play the video background 的本地化字符串。
+ ///
+ public static string SettingPage_AutoPlayVideoBackground {
+ get {
+ return ResourceManager.GetString("SettingPage_AutoPlayVideoBackground", resourceCulture);
+ }
+ }
///
/// 查找类似 Release History 的本地化字符串。
diff --git a/src/Starward.Language/Lang.resx b/src/Starward.Language/Lang.resx
index 28a72a513..79d819541 100644
--- a/src/Starward.Language/Lang.resx
+++ b/src/Starward.Language/Lang.resx
@@ -1863,6 +1863,9 @@ Do you accept the risk and continue to use it?
Registry-based Game Account Switching Feature
+
+ Automatically play the video background
+
ZZZ Gacha Item Images
diff --git a/src/Starward/AppConfig.Setting.cs b/src/Starward/AppConfig.Setting.cs
index 47570fd91..4bffc9dab 100644
--- a/src/Starward/AppConfig.Setting.cs
+++ b/src/Starward/AppConfig.Setting.cs
@@ -72,6 +72,12 @@ public static int VideoBgVolume
set => SetValue(value);
}
+ public static bool VideoBgAutoPlay
+ {
+ get => GetValue(true);
+ set => SetValue(value);
+ }
+
[Obsolete("已不用", true)]
public static bool UseOneBg
{
@@ -598,6 +604,21 @@ public static void SetGameBackgroundIds(GameBiz biz, string? value)
SetValue(value, $"game_background_ids_{biz}");
}
+ ///
+ /// 视频背景是否播放,null 表示未手动设置,跟随全局开关
+ ///
+ public static bool? GetVideoBgManualStop(GameBiz biz)
+ {
+ return GetValue(default, $"bg_video_stopped_{biz}");
+ }
+
+ ///
+ /// 视频背景是否播放,null 表示未手动设置,跟随全局开关
+ ///
+ public static void SetVideoBgManualStop(GameBiz biz, bool? value)
+ {
+ SetValue(value, $"bg_video_stopped_{biz}");
+ }
///
/// 启用 DX12
diff --git a/src/Starward/Features/Background/AppBackground.xaml.cs b/src/Starward/Features/Background/AppBackground.xaml.cs
index efe466c94..5dd1a37fc 100644
--- a/src/Starward/Features/Background/AppBackground.xaml.cs
+++ b/src/Starward/Features/Background/AppBackground.xaml.cs
@@ -246,7 +246,11 @@ public async Task UpdateBackgroundAsync(GameBackground? background = null)
CurrentGameBackground = gameBackground;
if (!apiCancelled && gameBackground?.Type is not GameBackground.BACKGROUND_TYPE_CUSTOM)
{
- AppConfig.SetBg(CurrentGameId.GameBiz, Path.GetFileName(filePath));
+ // 视频背景即使因暂停而渲染为静态图,仍持久化视频文件名,以保证恢复播放时能正确匹配
+ string persistName = gameBackground?.Type is GameBackground.BACKGROUND_TYPE_VIDEO
+ ? Path.GetFileName(gameBackground.Video.Url)
+ : Path.GetFileName(filePath);
+ AppConfig.SetBg(CurrentGameId.GameBiz, persistName);
var list = await _backgroundService.GetGameBackgroundsAsync(CurrentGameId);
AppConfig.SetGameBackgroundIds(CurrentGameId.GameBiz, string.Join(',', list.Select(x => x.Id)));
}
diff --git a/src/Starward/Features/Background/BackgroundService.cs b/src/Starward/Features/Background/BackgroundService.cs
index 3c9fce27b..425569889 100644
--- a/src/Starward/Features/Background/BackgroundService.cs
+++ b/src/Starward/Features/Background/BackgroundService.cs
@@ -147,18 +147,16 @@ public async Task> GetGameBackgroundsAsync(GameId gameId, C
string firstBgId = backgrounds.FirstOrDefault()?.Id ?? string.Empty;
if (!string.IsNullOrWhiteSpace(lastBg) && (lastBgIds?.StartsWith(firstBgId) ?? false))
{
- // 没有新背景
- if (backgrounds.FirstOrDefault(x => Path.GetFileName(x.Background.Url) == lastBg) is GameBackground bg1)
- {
- bg1.StopVideo = true;
- bg = bg1;
- }
- else if (backgrounds.Where(x => x.Video != null).FirstOrDefault(x => Path.GetFileName(x.Video.Url) == lastBg) is GameBackground bg2)
- {
- bg = bg2;
- }
+ // 没有新背景,沿用上次选择的背景
+ bg = backgrounds.FirstOrDefault(x => Path.GetFileName(x.Background.Url) == lastBg)
+ ?? backgrounds.Where(x => x.Video != null).FirstOrDefault(x => Path.GetFileName(x.Video.Url) == lastBg);
}
bg ??= backgrounds.FirstOrDefault();
+ // 视频背景是否播放,未手动设置时跟随全局开关
+ if (bg is not null && bg.Type is GameBackground.BACKGROUND_TYPE_VIDEO)
+ {
+ bg.StopVideo = AppConfig.GetVideoBgManualStop(gameId.GameBiz) ?? !AppConfig.VideoBgAutoPlay;
+ }
return bg;
}
diff --git a/src/Starward/Features/GameLauncher/GameLauncherPage.xaml.cs b/src/Starward/Features/GameLauncher/GameLauncherPage.xaml.cs
index 22d9a49a2..44931959b 100644
--- a/src/Starward/Features/GameLauncher/GameLauncherPage.xaml.cs
+++ b/src/Starward/Features/GameLauncher/GameLauncherPage.xaml.cs
@@ -990,12 +990,14 @@ private void ChangeBackgroundImageIndex(int index)
return;
}
GameBackground current = BackgroundImages[index];
- WeakReferenceMessenger.Default.Send(new BackgroundChangedMessage(current));
CanStopVideo = current.Type is GameBackground.BACKGROUND_TYPE_VIDEO;
if (CanStopVideo)
{
+ // 视频背景是否播放,在未手动设置时跟随全局开关
+ current.StopVideo = AppConfig.GetVideoBgManualStop(CurrentGameId.GameBiz) ?? !AppConfig.VideoBgAutoPlay;
StartStopButtonIcon = current.StopVideo ? PlayIcon : PauseIcon;
}
+ WeakReferenceMessenger.Default.Send(new BackgroundChangedMessage(current));
}
catch { }
}
@@ -1131,6 +1133,8 @@ private void StartOrStopVideoBackground()
if (current.Type is GameBackground.BACKGROUND_TYPE_VIDEO)
{
current.StopVideo = !current.StopVideo;
+ // 记录用户对该游戏视频背景是否播放的手动选择,覆盖全局开关的默认行为
+ AppConfig.SetVideoBgManualStop(CurrentGameId.GameBiz, current.StopVideo);
StartStopButtonIcon = current.StopVideo ? PlayIcon : PauseIcon;
WeakReferenceMessenger.Default.Send(new BackgroundChangedMessage(current));
}
diff --git a/src/Starward/Features/Setting/GeneralSetting.xaml b/src/Starward/Features/Setting/GeneralSetting.xaml
index 82e83011f..c3c211f8a 100644
--- a/src/Starward/Features/Setting/GeneralSetting.xaml
+++ b/src/Starward/Features/Setting/GeneralSetting.xaml
@@ -58,6 +58,11 @@
OffContent="{x:Bind lang:Lang.SettingPage_RegistryBasedGameAccountSwitchingFeature}"
OnContent="{x:Bind lang:Lang.SettingPage_RegistryBasedGameAccountSwitchingFeature}" />
+
+
diff --git a/src/Starward/Features/Setting/GeneralSetting.xaml.cs b/src/Starward/Features/Setting/GeneralSetting.xaml.cs
index 2fe4ca5ed..a8421e301 100644
--- a/src/Starward/Features/Setting/GeneralSetting.xaml.cs
+++ b/src/Starward/Features/Setting/GeneralSetting.xaml.cs
@@ -2,6 +2,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
+using Starward.Features.Background;
using Starward.Features.ViewHost;
using Starward.Frameworks;
using System;
@@ -197,6 +198,28 @@ public bool EnableGameAccountSwitcher
+ #region 自动播放视频背景
+
+
+
+ public bool VideoBgAutoPlay
+ {
+ get; set
+ {
+ if (SetProperty(ref field, value))
+ {
+ AppConfig.VideoBgAutoPlay = value;
+ WeakReferenceMessenger.Default.Send(new BackgroundChangedMessage());
+ }
+ }
+ } = AppConfig.VideoBgAutoPlay;
+
+
+
+ #endregion
+
+
+
#region 系统视觉效果