Skip to content

Commit

Permalink
#870 支持屏蔽彩色弹幕
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed Oct 19, 2024
1 parent fc57045 commit 06a8ed5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/BiliLite.UWP/Controls/PlayerControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,19 @@
</Grid>
<TextBlock Margin="0 8">屏蔽等级(0为不屏蔽) <Run Text="{x:Bind Path=DanmuSettingShieldLevel.Value,Mode=OneWay,Converter={StaticResource numberToStringConvert}}"/>级</TextBlock>
<Slider x:Name="DanmuSettingShieldLevel" Minimum="0" Maximum="10" StepFrequency="1"></Slider>

<Grid Margin="0 8 0 0">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ToggleSwitch x:Name="DanmuSettingDisableColorful" Foreground="White" >
<ToggleSwitch.Header>
<TextBlock Foreground="White" >屏蔽彩色弹幕</TextBlock>
</ToggleSwitch.Header>
</ToggleSwitch>
</Grid>

<TextBlock Margin="0 8">关键词屏蔽</TextBlock>
<Grid >
<Grid.ColumnDefinitions>
Expand Down
20 changes: 20 additions & 0 deletions src/BiliLite.UWP/Controls/PlayerControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,18 @@ private void LoadDanmuSetting()
await LoadDanmaku(segIndex);
}
};
//屏蔽彩色弹幕
DanmuSettingDisableColorful.IsOn = SettingService.GetValue<bool>(SettingConstants.VideoDanmaku.DISABLE_COLORFUL, false);
DanmuSettingDisableColorful.Toggled += async (e, args) =>
{
SettingService.SetValue<bool>(SettingConstants.VideoDanmaku.DISABLE_COLORFUL, DanmuSettingDisableColorful.IsOn);
if (!m_useNsDanmaku)
{
var segIndex = Convert.ToInt32(Math.Ceiling(Player.Position / (60 * 6d)));
if (segIndex <= 0) segIndex = 1;
await LoadDanmaku(segIndex);
}
};
//半屏显示
//DanmuControl.DanmakuArea = SettingService.GetValue<bool>(SettingConstants.VideoDanmaku.DOTNET_HIDE_SUBTITLE, false)?1:.5;
//DanmuSettingDotHideSubtitle.Toggled += new RoutedEventHandler((e, args) =>
Expand Down Expand Up @@ -693,6 +705,10 @@ private List<DanmakuItem> FilterFrostDanmaku(IEnumerable<DanmakuItem> danmakus)
{
danmakus = danmakus.Where(x => !Regex.IsMatch(x.Text, item));
}
//彩色
danmakus = danmakus.WhereIf(
DanmuSettingDisableColorful.IsOn,
x => x.TextColor == Colors.White);

// 同屏密度
if (max > 0)
Expand Down Expand Up @@ -745,6 +761,10 @@ private async Task SelectNsDanmakuAndLoad(int position, double level, bool needD
{
data = data.Where(x => !Regex.IsMatch(x.text, item));
}
//彩色
data = data.WhereIf(
DanmuSettingDisableColorful.IsOn,
x => x.color == Colors.White);
if (max > 0)
{
data = data.Take(max);
Expand Down
6 changes: 6 additions & 0 deletions src/BiliLite.UWP/Models/Common/SettingConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@ public class VideoDanmaku
/// </summary>
[SettingKey(typeof(string))]
public const string DANMAKU_FONT_FAMILY = "VideoDanmuFontFamily";

/// <summary>
/// 屏蔽彩色弹幕
/// </summary>
[SettingKey(typeof(bool))]
public const string DISABLE_COLORFUL = "DisableColorful";
}

public class Live
Expand Down

0 comments on commit 06a8ed5

Please sign in to comment.